5 Ways to Trigger UAC Elevation from Command Line

Most Windows users would have experienced the User Account Control window asking the user to confirm in allowing the app to make changes to their computer. This is because some folders such as Program Files, Windows and root of the drive don’t automatically grant write permissions to the user in question or to all users. So let’s say when you are trying to install Google Chrome, the UAC asks for permission because the setup is trying to install it in the Program Files folder.

Some applications such as the Command Prompt can run with or without the UAC elevation with the difference in the permissions. If the non-elevated command prompt is trying to do something such as deleting a file from the root of C drive which is out of their rights, then Windows will simply deny the action.

cmd access is denied

Attempting to perform the same action which is deleting the file but from the Windows Explorer, you are not automatically denied but instead you are given another chance to proceed by clicking the continue button. This means that there are additional restrictions when it comes to working in command prompt and oddly Microsoft has not included a command to trigger a UAC elevation from the command line. If you need to trigger a UAC elevation from command line in a batch file, here are 5 different ways to do it. 1. NirCmd

NirCmd is a super useful utility for command prompt power users. You will find it hard to believe that a small command line utility weighing just over 100KB in size is able to perform over 100 commands ranging from simply opening/closing the CD-ROM drive to even converting image formats. What we are looking for in NirCmd is the “elevate” command that allows you to run a program with administrative rights. Below is an example of launching command prompt as administrator using NirCmd’s elevate command.

nircmd elevate

You can run the command from anywhere such as batch file, shortcut or even in a Run window. If the path to the program contains a space, you’ll need to enclose the full path with quotes.

Download NirCmd


2. Elevate by Kai Liu

This small Elevate utility at 5KB in size is created by Kai Liu and it does only one thing that is executing a command with UAC privilege. It supports a few options such as launching a terminating or persistent command processor, enabling unicode support, waiting for termination and etc. Below is an example of using the Elevate tool to run command prompt as administrator.

kailiu elevate

The elevate tool comes in both 32-bit and 64-bit build to ensure full compatibility with the different Windows architecture.

Download Elevate by Kai Liu


3. Elevate by Johannes Passing

The name of this tool is also called Elevate but created by a different person using a different programming language. The earlier Elevate tool was created using native C code while this one by Johannes Passing is created using Visual Studio which resulted in a huge increase of file size at 90KB compared to only 5KB. This version offers a useful alternative if the earlier Elevate tool doesn’t work on your computer.

elevate jpassing

This Elevate tool only has 2 additional options which are to wait until the program terminates and enabling the %COMSPEC% environment variable value for programs that are executed in it. You can also find 2 different builds of this Elevate tool for x86 and x64 version of Windows.

Download Elevate by Johannes Passing


4. Elevate by John Robbins

Surprisingly this third tool is also called Elevate which can be quite confusing as there are now 3 different versions that pretty much do the same thing. This version of Elevate by John Robbins is slightly different in a way because it requires .NET Framework 3.5 to run and this framework is not enabled by default in Windows 8 and 10. However, the command options are exactly the same as the Elevate tool by Johannes Passing.

elevate jrobbins

We’ve tested this tool on 64-bit version of Windows 10, and it works fine after enabling .NET Framework 3.5 from Windows Features.

Download Elevate by John Robbins


5. PowerShell

Our fifth and final method does not involve any third party tool to trigger a UAC elevation on a command or program. As long as you’re running Windows 7 and above, the operating system itself already comes with PowerShell which looks similar to a command prompt but is more powerful because of the scripting language. The command line below is an example of using PowerShell to run a command prompt with UAC elevation.

powershell.exe Start-Process cmd.exe -Verb runAs

You should replace the cmd.exe with your preferred file or command, and optionally enclosed the command/path with quotes if there are spaces.

powershell trigger uac elevation


Additional Notes: The Run As Utility (runas.exe) included in the Windows operating system merely runs an application as another user, but does not trigger the UAC elevation. While you may see that running a command prompt with runas.exe does show the default location as C:\Windows\System32 instead of the user’s home folder, it does not have the administrator permission to manage files that are protected from all users.

2 Comments - Write a Comment

  1. xpclient 5 years ago
    • Kubo 5 years ago

Leave a Reply

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

Note: Your comment is subject to approval. Read our Terms of Use. If you are seeking additional information on this article, please ask in our forum or contact us directly.