batch file - Incorrect *.bat execution from Java -


this question has answer here:

i have .bat file following content example:

mkdir testdir 

now put folder c:\temp want run using java following:

runtime.getruntime().exec("cmd /c start c:\\temp\\test.bat"); 

i expect folder created in c:\temp when execute file manually, folder being created in workspace wrong. how can fix it?

you need specify working directory when run cmd.

there overloads of runtime.exec() allow specify working directory. example:

runtime.getruntime().exec("cmd /c start c:\\temp\\test.bat", null,                           new file("c:\\temp")); 

alternatively, can use processbuilder give rather more explicit control of various aspects of process you're starting.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -