Reputation: 134
When I try to run the command
C:\Windows\system32\cmd.exe /C "C:\Program Files (x86)\TorAES\certmgr.exe" -del -c -n "Certificatename" -s -r localMachine trustedpublisher
in a Windows cmd.exe I get the errormessage (translated by me): The command "C:\Program" is misspelled or does not exist.
even other combinations with " does not work:
C:\Windows\system32\cmd.exe /C 'C:\Program Files (x86)\TorAES\certmgr.exe' -del -c -n 'Certificatename' -s -r localMachine trustedpublisher
C:\Windows\system32\cmd.exe /C "'C:\Program Files (x86)\TorAES\certmgr.exe' -del -c -n 'Certificatename' -s -r localMachine trustedpublisher"
C:\Windows\system32\cmd.exe /C \"C:\Program Files (x86)\TorAES\certmgr.exe\" -del -c -n \"Certificatename\" -s -r localMachine trustedpublisher
Unfortunately if I just run
C:\Windows\system32\cmd.exe /C "C:\Program Files (x86)\TorAES\certmgr.exe"
certmgr.exe starts but (obvious) my arguments are missing and i really need them to automatic remove my certificate when uninstalling my program.
I am absolutly unfamiliar with batchscripting. Is someone able to find my mistake? Thanks!
Upvotes: 0
Views: 4192
Reputation: 103565
See cmd /?
:
If /C or /K is specified, then the remainder of the command line after the switch is processed as a command line, where the following logic is used to process quote (") characters:
If all of the following conditions are met, then quote characters on the command line are preserved:
- no /S switch
- exactly two quote characters
- no special characters between the two quote characters, where special is one of: &<>()@^|
- there are one or more whitespace characters between the two quote characters
- the string between the two quote characters is the name of an executable file.
Otherwise, old behavior is to see if the first character is a quote character and if so, strip the leading character and remove the last quote character on the command line, preserving any text after the last quote character.
So you can add an outer set of quotes:
C:\Windows\system32\cmd.exe /C ""C:\Program Files (x86)\TorAES\certmgr.exe" -del -c -n "Certificatename" -s -r localMachine trustedpublisher"
Upvotes: 1