Reputation: 388
How do you run a command using cmd (Windows 10) in java, using admin privileges, but without opening the program with admin privileges.
For example I would want to run a command like shutdown /i, this command does not need admin privileges but others I may run will.
Upvotes: 0
Views: 290
Reputation: 19252
On windows, runas
(run as ... ) allows you to run a program under another account.
Just runas
at a prompt for help.
For exmaple
runas /env /user:[email protected] "notepad \"my file.txt\""
You need quotes and uote escaping for parameters. but basically, runas who/where then your command.
Upvotes: 1