Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
possible duplicate: Is there any 'sudo' command for Windows? – Steve Rathbone Jun 16 '12 at 10:38

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.

share|improve this answer

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...

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .