windows - Not able to run .bat file with complete path with spaces -


i know question looks silly, struggling run .bat file. have .bat file located in below path. c:\realtime data export tool\exporttool\batchfiles notice spaces in root folder. , trying run .bat file directly prefixing path below:

c:\realtime data export tool\exporttool\batchfiles\exportdata.bat "dncorr" "system" "system123" "sync" "test" 

i getting below error:

'c:\realtime' not recognized internal or external command, operable program or batch file.

i dont want "cd folderpath" , run exportdata.bat. actual requirement have run windows command html page. javacsript constructs string , opens commandpromt run batch file. want accomplish in single command includes complete path .bat file. can please help?

edit - solution:

c:\realtime data export tool\exporttool\batchfiles\exportdata.bat "dncorr" "system" "system123" "sync" "test" 

... javacsript constructs string , opens commandpromt run batch file...

in other words, must invoke either cmd /c or cmd /k open command prompt... in case:

cmd /c "c:\realtime data export tool\exporttool\batchfiles\exportdata.bat" "dncorr" "system" "system123" "sync" "test" 

does not work , (cmd /?) explains, in case the first , last quote removed. hence, string of following (not exhaustive list, there others) using:

- surrounding additional quotes

""c:\realtime data export tool\exporttool\batchfiles\exportdata.bat" "dncorr" "system" "system123" "sync" "test"" 

- alternative quoting

c:"\realtime data export tool\exporttool\batchfiles\exportdata.bat" "dncorr" "system" "system123" "sync" "test" 

- call command (preferred)

call "c:\realtime data export tool\exporttool\batchfiles\exportdata.bat" "dncorr" "system" "system123" "sync" "test" 

- @ symbol

@"c:\realtime data export tool\exporttool\batchfiles\exportdata.bat" "dncorr" "system" "system123" "sync" "test" 

proof:

==>type "simple cli parser.bat" @echo  %%* = %*  ==>"simple cli parser.bat" "aa" bb  %* = "aa" bb  ==>cmd /c "simple cli parser.bat" "aa" bb 'simple' not recognized internal or external command, operable program or batch file.  ==>cmd /c ""simple cli parser.bat" "aa" bb"  %* = "aa" bb  ==>cmd /c simple" cli parser.bat" "aa" bb  %* = "aa" bb  ==>cmd /c call "simple cli parser.bat" "aa" bb  %* = "aa" bb  ==>cmd /c @"simple cli parser.bat" "aa" bb  %* = "aa" bb  ==> 

original answer:

try next batch see how parameters work:

@echo off >nul echo( echo before shift [%~1] [%~2] [%~3] [%~4] echo   %%* = %* echo( set /a "ii=0" :loopfor   echo param %%%ii% = %0   shift   set /a "ii+=1"   if not [%0]==[] goto :loopfor echo( echo after shifts [%~1] [%~2] [%~3] [%~4] echo   %%* = %* 

output:

==>"d:\bat\cli parser.bat" "a string spaces" stringwithout spaces  before shift [a string spaces] [stringwithout] [spaces] []   %* = "a string spaces" stringwithout spaces  param %0 = "d:\bat\cli parser.bat" param %1 = "a string spaces" param %2 = stringwithout param %3 = spaces  after shifts [] [] [] []   %* = "a string spaces" stringwithout spaces  ==> 

resources (required reading):


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -