There is something of a mantra in the IT world: If it has to be repeated more than once, script it and automate it. The same goes for Q&A. If more than one person asks about it, write it down. So here you go.
Why do you need to open an elevated command prompt? With newer Windows operating systems, certain files and functions are protected. Even if your user account is in the local administrators group, you still won’t be able to perform certain things on your computer.
For example, you may be testing network or internet enabled application, but you want the queries to go to specific server, like a dev/test copy of a database. One simple way of doing this is modifying your hosts file at C:\Windows\System32\drivers\etc. So you think, “No problemo!”
Not so fast, sparky. If you simply open the file in notepad, or use my preferred method of opening a command prompt, you’ll get either an access denied/save-as dialog (notepad method), or you’ll get a The requested operation requires elevation at which point you’ll be dumped back to the command prompt.
The good news is that it’s really easy to open an elevated command prompt, and the process is the same in Windows 7 and Windows 8.
- Tap the Windows key on your keyboard to bring up the Start menu or Start screen.
- Type CMD, and the command prompt shortcut will bubble to the top.
- Right-click the shortcut, and select Run As Administrator from the context menu.
- If you have UAC turned on, you’ll get a dialog asking if you are sure. Select the affirmative, and your elevated command prompt will be displayed.
If you want to bypass this process, you can turn off User Account Control (UAC) completely. I wouldn’t recommend it, though; it’s there for a reason.