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.
- Poll: How reliable are ChatGPT and Bing Chat? - Tue, May 23 2023
- Pip install Boto3 - Thu, Mar 24 2022
- Install Boto3 (AWS SDK for Python) in Visual Studio Code (VS Code) on Windows - Wed, Feb 23 2022
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.
Subscribe to 4sysops newsletter!
Some background on how the Script Elevation PowerToys work can be found in this TechNet article.