How to supply password to runas command when executing it from java

前端 未结 3 677
无人共我
无人共我 2021-02-13 15:03

I have to run a batch files from a java program which need administrative privilege. I am using the below command

runtime.getruntime().exec(\"runas /user:Admin \         


        
3条回答
  •  你的背包
    2021-02-13 15:27

    Try this

    runtime.getruntime().exec("cmd /C echo YOUR_PASS | runas /user:Admin \"C:\Program Files\test.bat\"");
    

提交回复
热议问题