So, I am running into a problem where I can’t seem to run the command without getting the following error message. Can someone give me some pointers as to what I am doing wrong? I am pulling the uninstall command from the registry and sending that information into a the variable $UninstallCMDfor the installed application and appending “/qn /norestart”. When I do this, I get the error message below.
It depends pretty much on the uninstall string you get from the registry and how you try to execute it.
BTW: Whatfor cmd? Powershell is a command line shell and is able to run either internal and external commands or tools. No need to start another command line shell from the current command line shell.
Generally speaking, as we cannot see what the actual uninstall variable string is, I would recommend you alter your syntax and make use of Start-Process:
However, given that from this syntax you can guess that $UninstallCMD is just a standard CMD command, you need not actually invoke cmd.exe to do this. Split your uninstall string into the executable being invoked (I’m guessing probably msiexec.exe?) and the arguments, and do it like this: