windows - Passing parameters (with spaces) to batch file from java program -
in program want execute jar parameters of .bat file.
.bat file
%6 -jar %5 -u %1 -p %2 -dbbkp %3 > %4 java program pass parameters above .bat file
string jarpath=request.getsession().getservletcontext().getrealpath("")+"/oes-smartclient/oes-smartclient.jar";  string outputfilepath=request.getsession().getservletcontext().getrealpath("")+"/resources/webfiles/oesfiles/dbbackupstatus.txt";   string jrepath="c:\\program files (x86)\\java\\jre7\\bin\\java";   string batfilepath = request.getsession().getservletcontext().getrealpath("")+"/web-inf/classes/oesdbbackup.bat";         string backuplocation = request.getsession().getservletcontext().getrealpath("")+"/web-inf/classes/backuplocation";          batfilepath="\""+batfilepath+"\"";         jarpath="\""+jarpath+"\"";         outputfilepath="\""+outputfilepath+"\"";         backuplocation="\""+backuplocation+"\"";      process = runtime.getruntime().exec(batfilepath +" "+ dbuser.getusername()+" "+ dbuser.getpassword()+" "+backuplocation+" "+outputfilepath+" "+jarpath+" "+jrepath); this above code taking database backup.
when running programs not giving error fail take database backup.
when giving backuplocation "c:\sm\"(without space parameter) working properly.
please can suggest me how pass parameters spaces.
 
 
  
Comments
Post a Comment