我正在尝试运行运行批处理文件的Java代码。但是没有管理员访问权限,我将无法运行
这会引发错误:-
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)
这是我的代码:-
String cmds[] = {"C:\\Users/Desktop/ex.bat"};
Runtime runtime = Runtime.getRuntime();
Process process = runtime.exec(cmds);
那么如何在我的Java代码中包括管理员访问权限?