Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 of How to run program from command line with elevated rights –  Oliver Salzburg Apr 27 '12 at 9:02
    
possible duplicate: Is there any 'sudo' command for Windows? –  Steve Rathbone Jun 16 '12 at 10:38

2 Answers 2

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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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