I need to run an .exe file through a batch file and redirect its output to a text file. The problem is that the path of the exe and the parameters that it gets have many spaces and backslashes and I can't get it to work. It either creates a blank txt file, or doesn't run my command at all (parses the command incorrectly).
The exe path: C:\Program Files (x86)\A S\Tools\Image\Image.exe
The parameters:
1) -v
2) C:\Program Files (x86)\A S\MyFiles\file_00_00_65
3) /0 /1 /2 /3 /5
4) C:\Program Files (x86)\A S\MyFiles\file_00_00_65\Images\AB.dtb
I have tried the following solutions:
A)
start "" "cmd /c ""C:\\Program Files (x86)\\AS\\Tools\\Image\\Image.exe" -v "C:\\Program Files (x86)\\A S\\MyFiles\\file_00_00_65" /0 /1 /2 /3 /5 "C:\\Program Files (x86)\\A S\\MyFiles\\file_00_00_65\\Images\\AB.dtb"" > Logs.txt 2>&1"
It fails: "C:\Program Files (x86)\A S\MyFiles\file_00_00_65\Images\AB.dtb"" couldn't be found.
B)
start "" cmd /c ""C:\\Program Files (x86)\\AS\\Tools\\Image\\Image.exe" -v "C:\\Program Files (x86)\\A S\\MyFiles\\file_00_00_65" /0 /1 /2 /3 /5 "C:\\Program Files (x86)\\A S\\MyFiles\\file_00_00_65\\Images\\AB.dtb"" > Logs.txt 2>&1
It fails: Creates an empty txt file.
C)
>Logs.txt 2>&1 (
start "" cmd /c ""C:\\Program Files (x86)\\A S\\Tools\\Image\\Image.exe" -v "C:\\Program Files (x86)\\A S\\MyFiles\\file_00_00_65" /0 /1 /2 /3 /5 "C:\\Program Files (x86)\\A S\\MyFiles\\file_00_00_65\\Images\\AB.dtb""
)
It fails: "\A was unexpected at this time."
D)
cmd /c ""C:\\Program Files (x86)\\A S\\Tools\\Image\\Image.exe" -v "C:\\Program Files (x86)\\A S\\MyFiles\\file_00_00_65" /0 /1 /2 /3 /5 "C:\\Program Files (x86)\\A S\\MyFiles\\file_00_00_65\\Images\\AB.dtb"" > Logs.txt | type Logs.txt
It fails: Creates an empty txt file.
I have also tried start /B /wait... and more.
ASin the code-path, notA S, yet you claim that there was a response (presumably from the executable) so therefore the executable was found. The response would seem to indicate that the quotes are being incorrectly interpreted - I'd remove thecmd/cand its surrounding quotes and dispose of the double-"myself - but I can'te test it since I don't have the executable in question.