windows - Running cmd with spaces from java -


i want run command through java session. command contains spaces. "c:\with space\sample.exe" -command_option "c:\source file\test.c" works if

c:\withoutspace\sample.exe -command_option "c:\source file\test.c" 

if keep quotes in c:\with space\sample.exe error :'the filename, directory name, or volume label syntax incorrect.' , if remove quotes exe not run... please guide.

thanks,

try this:

string[] arg = {"cmd","/c","c:/source file/test.c"}; processbuilder pb = new processbuilder(arg); process pr = pb.start();    

also, can use runtime.exec(string[]) version

example:

runtime rt = runtime.getruntime(); string[] args = { "cmd", "/c", "c:/source file/test.c"}; try {     process proc = rt.exec(processcommand); } 

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -