With Vista's UAC (User Account Control) enabled, you need an elevated command shell if you have to run commands with administrator privileges from the command line. This post explains how you can alter the Windows Explorer context menu to open an elevated command prompt in a certain directory using Microsoft's Script Elevation PowerToys (newer version here) for Windows Vista. The elevate.cmd that comes with the PowerToys allows you to launch commands and scripts with administrative rights from a non-elevated command prompt. You can also use them to elevate other file types such as MSI or MSP easily.

Latest posts by Michael Pietroforte (see all)

You probably know that you can launch a command prompt in Vista with the Windows Explorer by holding the shift-key and right-clicking on the folder where the commands you want to use are located. You will see the "Open Command Windows here" option in the context menu. This doesn't work in the left navigation pane of Windows Explorer, though. By the way, the context menu will show another useful option this way: "Copy as Path". It allows you to copy the corresponding path to the Windows Clipboard. This is sometimes useful if you need a directory path on the command line or in a script.

If you start a command prompt as described above, then Vista's UAC will make sure that it will only be opened with standard user rights. With the Script Elevation PowerToys, you can add several new options to the context menu of Windows Explorer. To install them you have to right-click on the corresponding inf file and navigate to "install".

Script Elevation PowerToys

The name of the inf files are self-explanatory. For example, after you installed ElevateComand.inf you will be able to launch elevated commands from the command prompt with elevate <application name>. You can also use this in scripts. The other inf files are for adding commands to the Windows Explorer context menu. For instance, installing PowerShellHereAsAdmin.inf will allow you to open an elevated PowerShell prompt by right-clicking on a folder in Windows Explorer. CmdHereAsAdmin does the same for Vista's command prompt.

Subscribe to 4sysops newsletter!

Some background on how the Script Elevation PowerToys work can be found in this TechNet article.

  1. Avatar
    Leonardo 16 years ago

    You beat me to the punch, just read about it while browsing MSDN… I already use an adaptation of the old powertoys to have a “cmd prompt here” context opiton… The elevated one is pinned to my start menu.
    I may check this out further, though, in this field (as you know), the more you know (even if you don’t use it right-a-way) the better.
    Wish I had a real need to learn WSH scripting, looks very powerfull, but my batch files still do all I need. One day…

    • Avatar
      Roger 4 years ago

      powershell is now supremacy.

      I'm a legendary developer 20+ years ..
      Now i can write ERP applications with powershell. Who needs .NET or visual compiler. lol. I can compile and sign code include SSL 2048 bit SSL cert. Let's do it. My ERP apps working been 3 years like a charm. Server core or NANO will do the job. Who needs a mouse these days …

  2. Avatar

    I wouldn’t start with learning WSH now. The future certainly belongs to PowerShell.


Leave a reply to Leonardo Click here to cancel the reply

Please enclose code in pre tags

Your email address will not be published. Required fields are marked *


© 4sysops 2006 - 2023


Please ask IT administration questions in the forums. Any other messages are welcome.


Log in with your credentials


Forgot your details?

Create Account