Run Command Prompt as the Administrator Automatically

Analysis
Oct 7, 20082 mins

Lots of the Windows Vista tweaks that I’m going to talk about here require an elevated Command Prompt session. The easiest way to get yourself an elevated command line is to click Start, type command, press Ctrl+Shift+Enter (or right-click Command Prompt in the search results and then click Run as Administrator), and then enter your UAC credentials.

That’s not a big deal if you require an elevated command prompt only once in a blue moon, but if it’s something you do regularly, even this simple technique can become a hassle. Even if you pin Command Prompt to the main Start menu, you still have to right-click and then click Run as Administrator, and at least half the time you’re either going to forget to do this, or you’re not going to realize that whatever you’re doing requires elevated privileges, and you have to bail out and start again.

To avoid these hassles, it’s possible to configure Windows Vista to always open Command Prompt in an elevated session. Here are the steps to follow:

  1. Open the Registry Editor.
  2. Navigate to the following key: HKCUSoftwareMicrosoftWindows NTCurrentVersionAppCompatFlagsLayers
  3. Select Edit, New, String Value. The Registry Editor creates a new value in the Layers key.
  4. Type C:WindowsSystem32cmd.exe and press Enter. (Modify the Windows location if yours is installed somewhere other than C:Windows):
  5. Double-click the entry you just created. The Edit String dialog box appears.
  6. Type RUNASADMIN and click OK.

Now, whenever you launch the command shell — either via the Start menu’s Command Prompt or via cmd.exe — you get the Administrator’s command line. The downside? You have to provide your UAC credentials ever time you need to use the command line.