0

I am trying to run the java code which runs a batch file. But without administrator access I am unable to run this

This throws error:-

java.io.IOException: Cannot run program "C:\Users/Desktop/ex.bat": CreateProcess error=2, The system cannot find the file specified
        at java.lang.ProcessBuilder.start(Unknown Source)

This is my code:-

String cmds[] = {"C:\\Users/Desktop/ex.bat"};
                Runtime runtime = Runtime.getRuntime();
                Process process = runtime.exec(cmds);

So how can I include administrator access in my java code ?

WhoAmI
  • 217
  • 1
  • 2
  • 23

0 Answers0