I know there are other questions here on Stackoverflow regarding this topic, but none of them resolved my case. I have a full path to a given program, examples might be:
- C:\"Program Files (x86)"\Lorem\program1.exe
- C:\"Program Files"\Ipsum\program2.exe
If I try to execute it directly on the terminal via C:\"Program Files (x86)"\Lorem\program1.exe /S it will run with no issues, but if I try using my script it won't work:
# $full_path contains the string for the path, e.g. C:\"Program Files (x86)"\supersoftware\uninst.exe
Write-Host $full_path # Will print on the screen: C:\"Program Files (x86)"\Lorem\uninst.exe
Invoke-Command -ComputerName localhost -ScriptBlock { cmd /c $full_path '"/S"' } # /S is used for silent uninstall
How can I make PS execute it as if I were there on the terminal typing C:\"Program Files (x86)"\Lorem\uninst.exe /S and hitting enter?
"C:\Program Files (x86)\Lorem\Program1.exe", notC:\"Program Files (x86)"\Lorem\Program1.exe"C:\..."with quotes outside and not inside. Now I'm getting a new error:'/S' not recognized as an internal or external command