Elevate - "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.
Synopsis:
elevate [(-c | -k) [-n] [-u]] [-w] command
Options:
-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" before attempting the privileged command, which can't be easily scripted.
This works well with "Elevate without prompting" in secpol.msc
. Together, they do the same as %wheel ALL=(ALL) NOPASSWD: ALL
in sudo
A known limitation is that it does not return the error code from the program it is elevating.
If your muscle memory is stuck on sudo, create an alias using Doskey:
doskey sudo=elevate -w
or batchfile in PATH:
@elevate -w %*
Elevate is 3rd party tool written by Johannes Passing. It's an 11kb download and portable (no install needed): http://code.kliu.org/misc/elevate/
7@IGRACH not on my powershell... – jiggunjer – 2016-01-17T15:27:10.890
2I use this
doskey sudo= runas /user:Administrator "cmd /k cd \"%cd%\" & $*"
– William – 2018-09-10T15:35:36.9571
Try my
– noseratio – 2019-02-16T07:39:40.987wsudo
, asudo
-like tool for Windows available as a Chocolatey package.2gsudo works in cmd/powershell/windows terminal and has some nice features. – Gerardo Grignoli – 2020-02-10T01:53:33.290
This may be old news now but I run windows 10 with windows-subsystem-for-linux enabled. For my wsl terminal I use Ubuntu. I never thought I would go for something like this as a linux user but it's actually pretty handy, plays nice with VS code as well.
– Jacksonkr – 2020-02-27T15:45:29.1737I 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 – 2014-01-25T01:01:01.767