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
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.
$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.
Thanks for the response! I’ll give this a shot tonight.