Tyrrrz/CliWrap

RunAs functionality

Closed this issue · 3 comments

Details

Greetings,

First off, I love CliWrap! I have used it now in several of my projects. Thanks for your efforts! You've really done a great job with this project!

I have a need to run some PowerShell scripts that need to be run with admin privilege. I do not see anywhere in your APIs where I can specify the Verb parameter on the process object. Am I missing it or do I need to request this feature? If it is there, I'd love to know how to run a process as administrator.

Also, I check the progress that Ukraine is making against the Russian aggressors. I read with joy whenever I see that Russia is in retreat, having their helicopters and aircraft knocked from the skies, and seeing the Russian cowards getting their asses kicked! All of Ukraine is in my thoughts and prayers, my friend!

Cheers,
Steve Miller

Hey there.

Unfortunately, running as admin is only possible via shell execute. This means that we won't be able to gain access to the process's output streams or do other things like kill the process on cancellation. This is a security limitation that prevents non-elevated processes from accessing information from elevated processes. In that state, 90% of CliWrap's functionality becomes effectively useless. Because of this, your best bet is to offer a prompt for the user to relaunch your own application with admin privileges, and then use CliWrap as you would normally to run other processes after that.

Cheers!