M2TeamArchived / NSudo

[Deprecated, work in progress alternative: https://github.com/M2Team/NanaRun] Series of System Administration Tools
https://nsudo.m2team.org/
Other
1.96k stars 224 forks source link

Elevate current process? #52

Open ci70 opened 3 years ago

ci70 commented 3 years ago

How to elevate current process in script?

MouriNaruto commented 3 years ago

If you wonder to run the app as the token from the current NSudo process.

Refer to https://m2team.github.io/NSudo/en-us/docs/#command-line

You can use -U:P parameter.

But if you need to elevate current process directly. NSudo and Priviexec aren't able to do it. (Because these tools don't need to load the driver. You can't replace the process access token unless you using a driver.)

Kenji Mouri

ci70 commented 3 years ago

-u:p will create process only.

Example how to do it. https://github.com/modzero/fix-windows-privacy/blob/master/fix-privacy-base/SelfElevate.cpp

MouriNaruto commented 3 years ago

OK, I understand what your mean.

Command line version of NSudo (NSudoC) don't elevate automatically because we take care about the command line experience. (Pop up the UAC window will break the immersive command line experience.)

In my opinion, you should elevate your script first. (If you don't do that and NSudoC supports the elevate automatically, the user of the script may suffer from multiple UAC pop up windows if you use NSudoC multiple times in your script.)

Kenji Mouri

MouriNaruto commented 3 years ago

@7wgs0gr04v Maybe I found the way to meet your requirement. But I need to try to implement first.