I've been pulling my hair out today about this one.

We have a whole bunch of SSIS packages (.DTSX files) that can be ran from the command line using dtexec.exe. There are spaces in the path to the package, the path to dtexec.exe and the path to the output file. To get around this I wrapped the paths including the file names in quotes so the spaces are preserved. Somehow I'm missing something because the command below does not work. I tried so many different ways to add the quotes all without success.

 Code:
...
$shellline = '%comspec% /c "D:\Folder\Folder with spaces\Tools\dtexec.exe" /file "' + $ssispackage + '" /de MySecretPassword >"' + $ssisoutput + '"'
...


When I display $shellline it shows the correct paths with quotes and all but when I run the script it says "D:\Folder\Folder is not recognized as an internal or external command, operable program or batch file" so it cuts the command at the first space. Running it without %comspec% /c works fine but I need this to be able to redirect the output of dtexec.exe to a text file. How do I properly pass the spaces to %comspec%? I thought I knew this but I guess not.

I double and triple checked all variables and they all show the correct path and filename with quotes to preserve the spaces. Have I been staring at this to long and going blind for the obvious issue or am I just going crazy?
_________________________
Mart

- Chuck Norris once sold ebay to ebay on ebay.