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 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.
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”.
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.
Some background on how the Script Elevation PowerToys work can be found in this TechNet article.




Subscribe via e-mail: 






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…
I wouldn’t start with learning WSH now. The future certainly belongs to PowerShell.