Author Posts

June 26, 2013 at 8:27 am

I need to execute a program.  The program has a switch that I need to pass to it.  The switch is throwing everything off.  I tried looking through the help and did not notice any options.

invoke-item "c:\test\text.exe"

I need to pass the switches /I and /Q

If there is a better way to accomplish outside of using invoke-item, I'm fine with that.

June 26, 2013 at 8:46 am

You don't need Invoke-Item.


c:\test\text.exe /I /Q

Should work fine. If it doesn't, and you're using PowerShell 3, consider using the "stop parsing the rest of this line" operator:


c:\test\text.exe %-- /I /Q

(from http://technet.microsoft.com/en-us/library/hh847892.aspx)

June 26, 2013 at 9:28 am

[quote=7894]You don’t need Invoke-Item.

c:\test\text.exe /I /Q

Should work fine. If it doesn’t, and you’re using PowerShell 3, consider using the “stop parsing the rest of this line” operator:

c:\test\text.exe %– /I /Q

(from http://technet.microsoft.com/en-us/library/hh847892.aspx) [/quote]

Don, that works perfectly thank you.  Is there some trick to getting it to work when spacing is applicable?  For example:

c:\test\test.exe works perfectly

c:\program files\test 1\test.exe does not work.  Enclosing it in single quotes or double quotes is not doing anything.

June 26, 2013 at 9:29 am

When spaces are involved, you need to use the invoke operator (&):

& "C:\Program Files\Some.exe" ...

June 26, 2013 at 9:41 am

[quote=7896]When spaces are involved, you need to use the invoke operator (&): & “C:\Program Files\Some.exe” … [/quote]

I just had my Ah Ha moment!  Thank you 🙂