Whilst setting up my new development environment in Windows 8 I ran into a little annoyance. I needed to edit my ‘hosts’ file to make local ‘.dev’ domain names. Generally, I would do this in Notepad++ (like everything else not PHP, HTML, JS, etc) but for some reason it won’t do it. So I end up using Notepad.
Using Notepad is annoying enough, but that isn’t what I am writing about. When opening the ‘hosts’ file in Notepad it wouldn’t let me save. Citing something about inadequate permissions. Apparently, you have to run Notepad in “Administrator Mode.” This is a pain in the ass because you can’t just go to Explorer, find the file, and do an “Open with…” command. You have to actually go to the sometimes handy, oft times infuriating Start Screen, find the Notepad tile, right-click it and chose “Run as administrator” option, and then find the file via Notepad’s “File > Open…” prompt. I edit the ‘hosts’ file quite a bit as I am constantly working on new projects, so this just wasn’t cutting it. After a bit of research I stumbled across Viper007Bond’s blogpost Editting Your Hosts File in Windows. This post show’s you how to create a shortcut that runs as administrator by default.
This is a simple thing to do and frankly I am embarrassed for not knowing it off-hand. Here is the fix:
- Open Explorer to the place that you want to put your shortcut (I like to put it in ‘C:\wamp\’)
- Right click an empty spot in Explorer to get the contextual menu and choose “New > Shortcut”
- Put the following in the textbox below the “Type the location of the item” label:
%windir%\system32\notepad.exe %windir%\system32\drivers\etc\hosts"
- Give the shortcut an appropriate name (i.e. “hosts”)
- Click the “Finish” button
- Now right click the newly created shortcut to view its contextual menu and click “Properties”
- Choose the “Advanced…” button
- Check the box labeled “Run as administrator”
- Click OK twice
Now when you open this shortcut you will be able to edit ‘hosts’ without hassle.
P.S.
This could be easily converted to a Start Screen tile if that is your thing.


