How to Elevate CMD to Admin on Windows: Step-by-Step

Most Windows users would have experienced the User Account Control dialog asking the user to allow a program to make changes to their computer. Some folders like Program Files, Windows, and the root of C don’t automatically grant write permissions to the user in question. For instance, when you try to install Google Chrome or 7-Zip, UAC asks for permission because it’s trying to install in the Program Files folder.

Some applications like the Command Prompt can run with or without the UAC elevation with the difference in the permissions it receives. If the non-elevated command prompt is trying to do something such as creating a file or deleting a file from the root of the C drive which it doesn’t have rights for, Windows will simply deny the action.

Cmd access denied

Microsoft has never included a simple tool to trigger a UAC elevation from the command line. You have to already be in an administrator Command Prompt to run elevated commands or run a batch script as administrator manually. If you need to trigger UAC elevation from the command prompt or in a batch file that doesn’t already have administrator privileges, here are six different ways to do it.

1. NirCmd

NirCmd is a super useful utility for many tasks and it’s just over 100KB in size. It can perform over 100 commands ranging from opening/closing the CD-ROM drive, or controlling system audio volume, to converting image formats. NirCmd has an “elevate” command that allows you to run a program with administrative rights. A command can be run from anywhere such as Command Prompt, a batch file, a desktop shortcut, or even in a Run window.

NirCMD Elevate cmd

Nircmd Elevate cmd /k fsutil volume diskfree c:

NirCmd Elevate notepad.exe C:\Windows\System32\Drivers\etc\HOSTS

NirCmd Elevate cmd /k “C:\Program Files\7-Zip\7z.exe” x C:\Users\Raymondcc\Desktop\arc.7z -oc:

Nircmd elevate 7zip

The first command will simply open an Administrator Command Prompt, the second runs FSUtil to get drive C: free space. The third command starts Notepad as an administrator while opening the HOSTS file with write access. The last command extracts an archived file to the root of C with 7-Zip. All commands will receive a UAC prompt to elevate their privileges.

Enclose any paths with quotes if they contain spaces. If you are running a command that shows information (like the FSUtil or 7-Zip examples), you can use “cmd /k” to keep the console window open once the command has finished. For best results, run NirCmd as administrator and let it copy itself to the Windows folder, then you don’t need to keep using the full path to it every time.

Download NirCmd

2. Gsudo

Gsudo is similar to the Sudo command found in operating systems like Linux that allows you to run commands with elevated privileges. This tool is quite powerful and has some useful features. It can run elevated commands in the current console window or spawn a new window, run commands directly, has PowerShell support, and includes a credential caching mode where a UAC prompt will only appear once per session.

Gsudo fsutil volume diskfree c:

Gsudo “C:\Program Files\7-Zip\7z.exe” x C:\Users\Raymondcc\Desktop\arc.7z -oc:


Run a Gsudo command from a standard Command Prompt that requires Administrator privileges and the UAC prompt will appear. The command will run in the same console window but you can add the “-n” argument to spawn a new window that will return once the command has completed. Use “-w” to wait for the process to finish before returning.

A recent update to Gsudo has turned the cache mode off by default. Enter “gsudo config CacheMode Auto” to turn the option on for all subsequent sessions. There are some other useful options like copying environment variables and network shares to the elevated session and running as the System account.

Download Gsudo

3. Elevate by Kai Liu

This small Elevate utility at 6KB in size is created by Kai Liu and it does the simple task of executing a command with UAC privilege. It supports a few options such as launching a terminating or persistent console window, enabling Unicode support and waiting for termination. The Elevate tool comes in both 32-bit and 64-bit builds to ensure compatibility, make sure you use the correct version.

Elevate -k fsutil volume diskfree c:

Kai liu elevate

The above command uses the “-k” argument to keep the target window open once the command completes. A useful feature is the current directory will be sent to the new console window, this can be stopped by adding the “-n” argument. For some reason, the developer distributes its tools as 7z archives so you will need 7-Zip or a comparable archiver to extract the files.

Download Elevate by Kai Liu

4. RunElevated

Run Elevated is a useful tool from Robtronic, which also produces the RunAsRob program. RunAsRob is useful for doing the opposite of what we want here and bypassing the UAC prompt for specific programs. This tool is useful for launching other programs, spawning admin Command Prompts, running batch files, or executing elevated console commands.

Runelevated notepad c:\windows\system32\drivers\etc\hosts

Runelevated cmd /k fsutil volume diskfree c:

Runelevated cmd /k “C:\Program Files\7-Zip\7z.exe” x C:\Users\Raymondcc\Desktop\arc.7z -oc:

Runelevated request UAC

The first command launches Notepad as administrator, the second runs a Windows console command that requires elevation while the third extracts an archive to the root of C. You might have to use “cmd /k” in the argument to launch the command and keep the console window open to display any information.

If you supply no arguments to Runelevated, it will pop up a box to manually browse for a file or even create a shortcut to launch on double click.

Download RunElevated

5. Elevate by Johannes Passing

The name of this tool is also called Elevate but is created by a different developer. This version offers a useful alternative if the earlier tools don’t work on your computer. You can also find two different builds of this Elevate tool for x86 and x64 versions of Windows.

Elevate -k fsutil volume diskfree c:

Johannes passing elevate tool

The tool only has 2 additional options which are to wait until the program terminates (-wait) and enabling the %COMSPEC% environment variable value for programs that are executed in it. Which is another way of saying using the “-k” argument will open a persistent console window.

Download Elevate by Johannes Passing

Elevate by John Robbins is pretty much an identical program with the same options. The only real difference is Johannes Passing took the John Robbins version and rewrote the code in C so it has no .NET Framework 3.5 requirement. They work exactly the same but if one version doesn’t work, you can try the other one.

Download Elevate by John Robbins

6. Command Prompt and PowerShell

This last method does not involve any third party tool to trigger UAC elevation. As long as you’re running Windows 7 and above, the operating system itself already comes with PowerShell which is powerful because of the scripting language. Below is an example of using PowerShell to launch a Command Prompt with UAC elevation. Remove “PowerShell” if you want to run the command from PowerShell itself.

Powershell Start cmd.exe -Verb Runas

Powershell launch admin cmd

Replace cmd.exe with your preferred file or command and optionally enclose it with quotes if there are spaces. The above command cannot run with arguments and you have to split things down into parts to do that on a single line. Adding “-ArgumentList” to the command comes in useful here.

Powershell Start Notepad.exe -ArgumentList “c:\windows\system32\drivers\etc\hosts” -Verb Runas

Powershell launch admin notepad

Like previously, this will start Notepad as administrator from the Command Prompt while loading the HOSTS file. To run a console command that requires elevation, such as Net, FSUtil, or BCDEdit, start cmd.exe and include the “/k” argument along with all subsequent arguments of the command split into elements of a string array.

Powershell Start cmd.exe -ArgumentList “/k”,”fsutil”,”volume”,”diskfree”,”c:” -Verb Runas

Powershell launch admin cmd args

We’ve used “fsutil volume diskfree c:” before in this article but as you can see here, each argument has to be separated. Quotes are not strictly required unless you have spaces in a path. The whole argument for ArgumentList can be enclosed in a single pair of quotes if you run the command from PowerShell, but running from Command Prompt seems to require the argument as a comma separated array.

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.

8 Comments - Write a Comment

  1. Gerardo Grignoli 4 years ago
    • Balazs Varnai 4 years ago
    • Tony 4 years ago
  2. Daniel Njuguna 4 years ago
    • Shivam Tomar 4 years ago
      • James C Rocks 3 years ago
  3. xpclient 12 years ago
    • Kubo 12 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 contact us directly.