In a "child.cmd" file, I have the following command:
DTEXEC.EXE /FILE "\"%~dp0..\SSIS Packages\%stepName%.dtsx\"" /CONNECTION DestinationConnectionOLEDB;"\"Data Source=%serverName%;Initial Catalog=%databaseName%;Provider=%databaseProvider%;%security%;Auto Translate=false;\"" /CONNECTION SourceConnectionExcel;"\"Provider=%excelProvider%;Data Source=%~dp0..\Excel Import Files\BAs Code Tables.xlsx;Extended Properties=%extendedProperties%;HDR=YES;\"" /CHECKPOINTING OFF /REPORTING %reporting% > "%~dp0..\Logs\Import\%stepName%.txt"
Essentially, I'm using DTEXEC.EXE to execute an SSIS package, and send the output to a text file. If I double click "child.cmd" everything works great.
However, if I try and call "child.cmd" from another batch file, say "parent.cmd", it no longer works. My "parent.cmd" file looks like:
call "%~dp0""Batch Files\child.cmd"
When I run "parent.cmd", it seems that the parameters I'm trying to pass into DTEXEC.EXE in my "child.cmd" file are no longer formatted the same, which causes the error:
Option "Files\..\SSIS" is not valid.
Where "Files..\SSIS" is a part of the /FILE file path input. There is a space before the "Files" portion of that path. Does anyone know what is going on here?
Note: A lot of the variables return text in double quotation marks because there are spaces. I feel like anywhere there are spaces is what is causing the problem. I don't know why the problem is only showing up when trying the run it as a child batch.
Edit: "child.cmd" is a folder deeper than "parent.cmd". I have updated my code above where I'm calling "child.cmd" in "parent.cmd". In addition, I do not set CD in my cmd files, and my googling seems to show that is not particularly easy to do when you don't know what file location "parent.cmd" is going to be run from, as is the case here.