I always work on a non-administrator account on my Windows computer. Sometimes I need to install programs which requires administrator access. As I mostly use the Windows command prompt, is there a Windows command to escalate privileges, similar to the Linux terminal command sudo?

  • 7
    I believe the term you are looking for is "elevated" access. Even though your credentials have admin permission, processes under your credentials don't have admin permissions until you "sudo" the command. In Windows, they call it "elevate". – surfasb Jan 25 '14 at 1:01
  • 7
    @IGRACH not on my powershell... – jiggunjer Jan 17 '16 at 15:27
  • 2
    I use this doskey sudo= runas /user:Administrator "cmd /k cd \"%cd%\" & $*" – William Sep 10 '18 at 15:35
  • 1
    Try my wsudo, a sudo-like tool for Windows available as a Chocolatey package. – noseratio Feb 16 at 7:39

15 Answers 15


The runas command.

runas [{/profile|/noprofile}] [/env] [/netonly] [/smartcard] [/showtrustlevels] [/trustlevel] /user:UserAccountName program

Just run:

runas /noprofile /user:Administrator cmd 

to start a command shell as a administrator

  • 22
    You might find you want the profile loaded (e.g. including environment variables) for any extended use. In which case drop the /noprofile. – Richard Sep 17 '09 at 9:38
  • 6
    This is not working for me. After I typed my password the command prompt is closed. – Jonas Dec 9 '10 at 13:44
  • 56
    isn't this asking for the Administrator's password? sudo is asking for your password! – n611x007 Sep 18 '12 at 8:42
  • 15
    Unfortunately, this is seriously outdated. Runas merely runs commands under a different set of credentials. Even though your credentials have admin permissions, it doesn't mean all processes under your credentials run as admin. – surfasb Jan 25 '14 at 0:59
  • 12
    +1 for "outdated" since runas can't bypass UAC. Instead, press Windows button, type cmd, and press Ctrl+Shift+Enter. – mellow-yellow Jan 22 '16 at 12:06

I discovered elevate today which "executes a command with UAC privilege elevation. This is useful for working inside command prompts or with batch files." It's not the same as sudo, it changes the executing user to Administrator, but its syntax is a lot more straightforward to use than runas, and it can keep the current directory, enabling the use of relative paths.

  elevate [(-c | -k) [-n] [-u]] [-w] command

  -c  Launches a terminating command processor; equivalent to "cmd /c command".
  -k  Launches a persistent command processor; equivalent to "cmd /k command".
  -n  When using -c or -k, do not pushd the current directory before execution.
  -u  When using -c or -k, use Unicode; equivalent to "cmd /u".
  -w  Waits for termination; equivalent to "start /wait command".

Elevate's purpose isn't to work around or bypass UAC (User Account Control), but to work with it. As long as UAC is enabled there has to be some kind of prompt at some point in the process. If you need to get rid of prompting altogether you have to disable UAC.

The pain point elevate alleviates is escalating a particular process from a non-privileged shell, and then carrying on as normal. Without this you need to start a privileged command prompt with right-click > "Run as Administrator", which can't be easily scripted, before attempting the privileged command.

  • 5
    This goes perfect with "Elevate without prompting" in secpol.msc. Together, they do the same as %wheel ALL=(ALL) NOPASSWD: ALL in sudo. – sayap Feb 20 '12 at 9:40
  • 2
    @sayap, just to be clear, do you mean this: ss64.com/nt/syntax-uac.html? – matt wilkie Feb 20 '12 at 18:45
  • 5
    The only trouble I find with elevate (v1.3.0) is that it does not return the error code from the program it is elevating. – Ken Aug 14 '13 at 18:41
  • 4
    Sudo.bat : @elevate %* => profit! – Joe DF Mar 12 '14 at 5:06
  • 10
    Would be nice to mention that it's an external utility, missing OOTB. – Hi-Angel Dec 27 '16 at 16:18

You can use the runas command which is kind of similar, or you can check out the sudo for Windows project over at SourceForge which adds a sudo command.

The difference is subtle:

Let's say you have two users. Bob is a normal user and James is an administrator.

If you log in as Bob and use "runas james acommand" the command is run as if it was run by James, so it accesses James' user settings and any user changes go into James My Documents & settings folders, etc. So if you are installing an application, say, it will be installed as James, not as Bob.

If on the other hand Bob does "sudo acommand" the command is still run as Bob, but with elevated permissions - just like the Linux sudo command. To prevent any user from being able to sudo you have to define a sudoers user group that contains the list of the normal users that have permission to elevate using sudo. The users still have to provide credentials before elevation.

Sometimes the difference isn't important, sometimes it is, and I find that both commands can be useful.

  • 2
    Are you sure? When I run sudo in ubuntu, if my current theme is in ~/.themes then the sudo-ed application will not be able to access that theme, because it's not in /home/root/.themes, and will use the default ugly gtk theme. – hasen Nov 19 '09 at 22:28
  • 5
    @hasen j - your issue is just because ~/.themes evaluates before the command is run (and thus before it switches over to root). – Jared Dec 15 '11 at 18:52
  • 1
    Another solution, except hosted on GitHub, is windosu: github.com/tehsenaus/windosu I just found it, and it seems to work great. Favorite thing is it's super easy to install. Just "npm install -g windosu". – Venryx Jun 6 '17 at 7:52

You can also use the Script Elevation PowerToys.

  • Awesome - exactly what I was looking for. I didn't want to run as a command has a different user, only to run it with elevated privileges. – orip Mar 14 '10 at 12:55
  • Exactly the right solution for this problem! Who wants Runas with its messy syntax? – Stabledog Mar 29 '10 at 14:14
  • 1
    I've often wished the elevate command were built into windows. It's a fantastic tool. – nhinkle Nov 11 '10 at 23:43
  • there's now an Elevation PowerToys collection by the same author from which Creating a Self-Elevating Script is particularly relevant. – matt wilkie Sep 7 '11 at 23:22
  • 1
    @barlop of course not. That would defeat the purpose of UAC. – nhinkle Mar 15 '14 at 17:07

If you are ready to switch to alternative consoles, there is ConEmu (I'm the author). One of its features - the ability to run both elevated and non-elevated tabs in the one ConEmu window. Tabs may be started with different credentials too.

For user comfort, there is batch-file csudo.cmd (which may be easily adopted to bash). Read full description in project's wiki. In brief, when you run some command from existing non-elevated tab, for example

csudo dism /online /enable-feature /featurename:NetFX3 /All /Source:D:\sources\sxs /LimitAccess

ConEmu will starts dism in the new elevated console/tab (with preceding UAC prompt in Vista or Login box in XP).

By default csudo starts new console in a split (may be changes via editing of csudo.cmd contents).

And of course you may rename it to sudo.cmd if you like "classic" sudo word.

sudo in ConEmu/Windows

  • 1
    csudo long ago was included in the ConEmu distribution. No link is needed at all. – Maximus Mar 12 '14 at 8:16
  • problem here is the new console tab becomes unusable after the sudo'd command. So you can't continue working in the elevated tab, just get a press enter or esc to exit message. – jiggunjer Jan 17 '16 at 15:25
  • 1
    Of course you cant. Even on Unix you are back to non-elevated terminal after sudo command is done its work! You are going wrong way. – Maximus Jan 17 '16 at 17:45
  • 1
    1) if you're gonna open a new window or tab you might as well keep it, let the user choose if they want to continue. 2) On my ubuntu I don't have to sudo every time, elevation lasts a few minutes I think. 3) this application has a million options, yet nothing for this? Maybe I'm spoiled. – jiggunjer Jan 18 '16 at 2:31

Quick method:

Three steps to add sudo.

  1. Open PowerShell.

  2. Copy the following script (Ctrl+C) and paste it in PowerShell (Alt+Space+E+P):

$script_path="$HOME\Documents\Scripts"; if (!(test-path $script_path)) {New-Item -ItemType directory $script_path} if (!(test-path $profile)) { new-item -path $profile -itemtype file -force }". $script_path\sudo.ps1" | Out-File $profile -append; "function sudo(){if (`$args.Length -eq 1){start-process `$args[0] -verb `"runAs`"} if (`$args.Length -gt 1){start-process `$args[0] -ArgumentList `$args[1..`$args.Length] -verb `"runAs`"}}" | Out-File $script_path\sudo.ps1; powershell
  1. Hit Enter.

It will permanently enable sudo command in PowerShell.


sudo <process-name> [param1 [param2 [param3]]]


sudo explorer
sudo notepad
sudo powershell
sudo cmd
sudo taskmgr
sudo tasklist
sudo taskkill /IM Skype.exe /PID 8496

Long method for learning:

Note: I mixed the script from both articles to create the aforementioned script. Rather manually pasting the script in notepad I added the Out-File statements to save ps1 and $profile files from the script.

Tip: If you are not a very big fan of UAC popups (like me), save the following in *.reg file and run it:

Windows Registry Editor Version 5.00
  • 1
    I love the powershell solution for this question. This has to be the easiest way to elevate something. Existing .bat files can easily be converted to POSH – Mitchell Skurnik Feb 14 '13 at 18:05
  • Got this error on windows 10: . : File C:\Users\User\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 cannot be loaded because running scripts is disabled on this system. – sowrov Nov 19 '15 at 9:51
  • @sowrov, see [this article](www.faqforge.com/windows/windows-powershell-running-scripts-is-disabled-on-this-system/). By default PowerShell scripts are disabled on any Windows installation. You need to enable it with this command set-executionpolicy remotesigned. Other options besides remotesigned are described in official docs. – vulcan raven Nov 22 '15 at 9:54
  • Readers note this ps script is a wrapper for the powershell -c start -verb runas program.exe functionality. Also note you can't elevate like this with the cmd prompt (natively). Powershell is the best native option. – jiggunjer Jan 17 '16 at 13:58
  • can the same be done in cmd.exe instead of powershell env? powershell does not compute with clink and without clink windows does not compute at all... – PJJ Feb 26 at 7:39

If you're doing this on Windows, then in addition to the Run As command as mentioned in a couple of other answers, there are also ways to do this with the mouse.

If you hold down the Shift key as you right-click on most executable files in Windows you should notice a few more advanced options. One of these is the "Run As..." option (I think it's called "Run As Administrator" from Vista onwards).

You can also download a more advanced version of RunAs from Microsoft, called ShellRunAs, this has enhancements over the built-in RunAs command, both in command line and graphical modes, including letting you save account credentials


There is a chocolatey package for it with the convenient name sudo. You can install the package with chocolatey using this command:

choco install -y sudo

Then in whatever Windows/MS shell you have to use, you can use sudo as expected.


Surun is free, open-source application that allows certain programs to run with administrative rights, without providing a password without changing the user registry or modify environment variables.

When I was using Windows XP this app helps me a lot. Beta works under Windows 7.

  • surun does a great job. However sometimes under Windows 8 and 8.1 its defaults aren't ideal. Because it replaces Windows's run as function, you are not able to start a command prompt with right click on the start screen. – Wolf Jan 15 '15 at 11:15

As you've probably discovered, runas will let you run as another user but it cannot do elevation and it doesn't pass current directories, environment variables or long command lines.

Hamilton C shell solves that with a genuine su and sudo. su lets you run a command as another user; sudo (actually an alias to su) lets you run a command elevated. You can also do both, running elevated as a different user. Current directories, environment variables and long command lines are passed by way of a shared memory handshake between su running in the caller's context and a copy of itself running as an interlude with the new credentials that then starts the child. Full disclosure: I'm the author.


A working sudo replacement for Cygwin's mintty terminal would be to place the following script in user's PATH:

cygstart --action=runas mintty -e `which bash` -lc \"$@\"

For me this is the only viable replacement to elevate privileges of programs like vim or cygrunsrv while working in a terminal on Windows.


This script does the job:

@echo Set objShell = CreateObject("Shell.Application") > %temp%\sudo.tmp.vbs
@echo args = Right("%*", (Len("%*") - Len("%1"))) >> %temp%\sudo.tmp.vbs
@echo objShell.ShellExecute "%1", args, "", "runas" >> %temp%\sudo.tmp.vbs
@cscript //NoLogo %temp%\sudo.tmp.vbs

Save it as sudo.cmd then add it to your PATH

Note: the runas means in this context "Run as administrator" and not "Run as other user"

Taken from here and slightly edited to remove cscript.exe header from output

  • 1
    This creates a new console. The new window will disappear after the sudo'd command is completed--so you can't even read output. – jiggunjer Jan 17 '16 at 14:09
  • Sadly, yes. But it can be used for some basic commands (copy), GUI tools, or opening an admin cmd. – Charles Milette Jan 17 '16 at 18:04

The simplest solution in my view is to leverage powershell to do the work, which is portable and will prompt the user using the UAC.

You can just run this in any shell (cmd or powershell)

powershell Start-Process -verb runAs path-to-your.exe "-all -args -in -quotes"

The following vbs script allows to launch a given command with arguments with eleventation. I put it on C:\Windows\System32

Set objArgs = WScript.Arguments
exe = objArgs(0)
args = ""
IF objArgs.Count >= 2 Then
   args = args & objArgs(1)
End If
For it = 2 to objArgs.Count - 1
   args = args & " " & objArgs(it)
Set objShell = CreateObject( "WScript.Shell")
Set objShellApp = CreateObject("Shell.Application")
objShellApp.ShellExecute exe, args, "", "runas", 1
set objShellApp = nothing

Example use on a command prompt sudo net start service

  • Downvoters: еxplain why and what is not working for you. The script is tested and working for me. – ceztko Nov 6 at 19:56

All the answers explain how to elevate your command in a new console host.

What amused me was that none of those tools behave like *nix sudo, allowing to execute the command inside the current console.

So I wrote my own. Welcome gsudo

gsudo demo

Source Code https://github.com/gerardog/gsudo

Download https://github.com/gerardog/gsudo/releases/

protected by slhck Aug 29 '12 at 18:25

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.