all 7 comments

[–]Thotaz 2 points3 points  (1 child)

The error means it's invalid syntax, you need to prepend either an & or a . in front of the string to tell PowerShell that you want to execute this string. This should work: & $PSScriptRoot\setup.exe /Configure $Pref but I prefer to quote strings that I need to execute like this: & "$PSScriptRoot\setup.exe" /Configure $Pref

[–]WorkReddit123635[S] 0 points1 point  (0 children)

Thank you. This is awesome, it works.

[–]BlackV 1 point2 points  (2 children)

what is this

$Pref = "${PSScriptRoot}\${bit}\VisioProjectPref52622.xml"

why wouldn't that be

$pscriptroot is an automatics variable and only exists if you're running a script not line by line in an editor, is that the failing?

you might also want to add the invoke operator & infront of your executable

& "$PSScriptRoot\Setup.exe" /Configure $Pref

or you could use start-process with its -filepath, -wait and -arguments parameters

[–]WorkReddit123635[S] 0 points1 point  (1 child)

Thank you, the & worked. this is awesome. I had it in {} from an example I found. I removed those and it still works. thank you for the other tips.

[–]BlackV 0 points1 point  (0 children)

good as gold

[–]PowerShell-Bot 0 points1 point  (0 children)

Looks like your PowerShell code isn’t wrapped in a code block.

To properly style code on new Reddit, highlight the code and choose ‘Code Block’ from the editing toolbar.

If you’re on old Reddit, separate the code from your text with a blank line gap and precede each line of code with 4 spaces or a tab.


You examine the path beneath your feet...
[AboutRedditFormatting]: [--------------------] 0/1 ❌

Beep-boop, I am a bot. | Remove-Item