I want to execute a bat file located remotely on server
\\testserver\someFolderName\test.bat.
I am using process builder and wanted to chande the directory with
procbuilder.directory(....),
but could not succeed.
Any help is appreciated. Thanks
解决方案
This is working code that we are using currently:
try {
ProcessBuilder launcher = new ProcessBuilder();
Map environment = launcher.environment();
launcher.redirectErrorStream(true);
launcher.directory(new File("\\\\\\TIERS\\DEV1\\RP\\VISUAL_BASIC\\"));
environment.put("name", "var");
launcher.command("your.exe");
Process p = launcher.start(); // And launch a new process
} catch (Exception e){
e.printStackTrace();
}