In Linux, one can do su to become root (Administrator) for multiple commands, or sudo ... to run one command as root.

Is there something similar in Windows, for either PowerShell or cmd.exe, that allows me to run a command with elevated permissions (like creating a symlink) without opening a new window?


Sudo for cmd

@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 %temp%\sudo.tmp.vbs

Not my code, just passing it on. Save it as sudo.cmd and pop it into system32 or somewhere within your PATH and you can do things like:

sudo test.bat

And test.bat would run with elevated permissions.


In powershell there is the cmdlet Get-Credential, you can even assign it to a variable and use it in your powershell commands later.

See this link for more information...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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