I am trying to execute an .exe file via a command line script on Windows (batch file). Actually my script does a lot more before executing the file (generating XML config files and such), however, theses parts work just fine, so I will just concentrate on the non working part of the script here.
I think that the spaces in the command to execute the .exe file might be the source of the error. However, when enclosing the line with " " it still won't work.
Echoing the line only works with the line enclosed by " " (that's why I am guessing that spaces or maybe some special characters or something cause this problem?). The path it echoes is correct though (checked via copy&paste into the explorer. Application started properly).
Here's the error message: the filename directory name or volume label syntax is incorrect
And the relevant code extract:
rem Start .exe file with parameters
@echo off
setlocal
rem List of keydates
set "list=20131231 20121231 20111231 20101231"
set "appPath=C:\Program Files (x86)\xxx\yyy\"
set "configPath=C:\Users\username\Desktop\batch test\"
rem [...] more vars here
for %%i in (%list%) do (
(
rem [...]
rem Generation of XML file, works just fine
rem [...]
)>BatchConfigTest_%%i.xml
rem Batch file is located in config path, this is why I define no explicit path here
)
rem Problem is located here
rem How do I execute the exe correctly? This approach doesn't work
for %%i in (%list%) do (
%appPath%ApplicationXYZ.exe -xmlcommandconfig:"%configPath%BatchConfigTest_%%i.xml
rem echo "%appPath%ApplicationXYZ.exe -xmlcommandconfig:"%configPath%BatchConfigTest_%%i.xml""
rem Echo shows correct paths. Copying the paths from the command line and pasting them into the explorer works.
)
pause