This topic contains 3 replies, has 4 voices, and was last updated by
March 23, 2018 at 9:25 pm #96975ParticipantPoints: 0Rank: Member
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.
Command= cmd.exe /c ($UninstallCMD) /qn /norestart
'/qn' is not recognized as an internal or external command, operable program or batch file.
Thanks for any pointers I may receive.
March 23, 2018 at 10:27 pm #96986ParticipantPoints: 727Rank: Major Contributor
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. 😉
March 24, 2018 at 12:34 pm #97005ParticipantPoints: 67Rank: Member
You can use the example below and see if that works. If you put the '–%' after the external command Powershell will not try to parse any of it.
c:\windows\system32\sc.exe –% qc bits
Whatever switches or values you would use for that command in the command prompt just add after the two dashes and percent.
March 25, 2018 at 12:09 am #97022ParticipantPoints: 398Rank: Contributor
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:
Start-Process -FilePath "cmd.exe" -ArgumentList '/c $UninstallCMD', '/qn' '/norestart'
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:
Start-Process -FilePath "msiexec.exe" -ArgumentList $Arguments, '/qn', '/norestart'
The topic ‘Executing old tools (cmd.exe)’ is closed to new replies.