Github – Sudo For Windows

I always work on a non-administrator account on my Windows computer. Sometimes I need to install programs which requires administrator access. As I mostly use the Windows command prompt, is there a Windows command to escalate privileges, similar to the Linux terminal command sudo?

*

*

The runas command.

Đang xem: Github

runas <{/profile|/noprofile}> /user:UserAccountName programJust run:

runas /noprofile /user:Administrator cmd to start a command shell as a administrator

*

*

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.

Xem thêm: Refurbished Blackberry Playbook Tablet With 32Gb Memory 38548

Synopsis: elevate <(-c | -k) <-n> <-u>> <-w> commandOptions: -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.

Xem thêm: Đồng Hồ Xiaomi 3 – Vòng Đeo Tay Thông Minh Xiaomi Mi Band 3

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/

Leave a comment

Your email address will not be published. Required fields are marked *