Author Posts

May 15, 2017 at 1:40 am

I'm having issues making ArugmentList on Start-Process respect special characters and my google fu is failing me.

This script block works fine

Start-Process .\process.exe -ArgumentList """D:\Folder\[] Derp.txt"""

But I cannot find a way to make it work with $FileName instead of D:\Folder\[] Derp.txt

May 15, 2017 at 3:12 am

A couple of things. If you look at the documentation for Start-Process, ArgumentList is a string array (string[]). Second, when you use double qoutes, Powershell will attempt to resolve that string and expand variables, etc. versus single qoutes are literal.

Try this:

$path = "D:\Folder\[]"
$fileName = "Derp.txt"

Start-Process .\process.exe -ArgumentList $path, $fileName

If that still doesn't work, try changing the double qoutes to single qoutes to basically force Powershell to treat the variables as strings.

May 16, 2017 at 4:52 pm

Thanks for the response! I'll give this a shot tonight.