0
I have a powershell script that iterates through all the services listed under HKLM:\Systemn\ControlSet001\services\
looking for the ImagePath
to see if it has any spaces but no quotes.
e.g.
C:\this is\very bad\but people\do it\anyways.exe
But, these may contain switches/parameters like:
C:\this is\very bad\but people\do it\anyways.exe -foo -bar -ray:JkLmOpQ
-or- C:\this is\very bad\but people\do it\anyways.exe /foo /bar /ray:JkLmOpQ
It's simple enough to just wrap things without parameters in quotes,
e.g.
$foo = "`"$bar`""
However, I'd like to handle things that may have parameters properly, e.g.
"C:\this is\very bad\but people\do it\anyways.exe" -foo -bar -ray:JkLmOpQ
"C:\this is\very bad\but people\do it\anyways.exe" /foo /bar /ray:JkLmOpQ
Considering using RegEx or splitting the string on /
or -
but those might have edge cases I'm missing.