Ive got a java app which needs to execute a driver installer exe file. On Linux we type "gksudo myCommand". Is there a way to elevate permissions from Windows command line?
3 Answers
You may run every application in windows with a different user e.g. Administrator. But the user who executes this command needs to have the credentials to do so.
Edit.:
In advance you can lookup the User Account Control (UAC) which is available in Windows 7 and Vista if it is possibly an alternative for you.
-
what about the UAC popup that says something like... this app is requesting permissions... How do I invoke that? Jul 4, 2011 at 6:06
-
There must be a better way.... I could always request that the user type their password with runas /user:administrator /savecred my command... then just pipe their answer into my stdin Jul 4, 2011 at 6:09
-
The thing is you are doing the same things in linux aswell gksudo or plain sudo is nothing else than running a command as different user with superuser rights(in the case of linux as root). I edited my post and added the UAC to it.– fyrJul 4, 2011 at 6:14
I decided to deploy an executable binary onto the system which calls the jar. This way the user can right click and run as administrator... That didn't work... SO I kept looking... Check this out..
Elevate.exe.. It's basically like Windows GKSudo!!!! http://www.robotronic.de/elevate.html
So... I packaged the 32bit exe into my program and deploy it, then run it as necessary.
You can use runas
command like runas /user:Administrator myCommand
(it requires the users to type password).
You can also use Start-Process
cmdlet like Start-Process -Verb runas myCommand
in PowerShell (it requires the users to click the UAC dialog).