1

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?

2

2 Answers 2

0

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.

0

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

You must log in to answer this question.

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