I was looking for an alternative for an unins开发者_Go百科tall in a setup project (while reading this) and tried the following, which sadly fails:
I made a Setup Project for a dummy application in C#. I added the output from its build and an Uninstall.bat file with this inside:
echo %1
msiexec /x %1
I then added a shortcut to that file with [Product Code]
in the shortcut's Arguments field:
My rationale was that Uninstall.bat would be called with the product code (resolved) as an argument.
After setting that up, no dice, the argument isn't passed along to the installer from the shortcut. The output from the command window is:
ECHO is on. msiexec /x
The %1
parameter doesn't seem present. Looking inside the LNK file in a binary editor, the product code appears to be present.
What's happening here?
Further attempts for various arguments and a simple echo:
[Product Code]
-> ignored{%hardcodedProductCode%}
-> passed to batch as%1
[Product Name]
-> ignoredConstant [Product Code]
-> Constant only is passed to batch as%1
[Product Name] Constant [Product Code]
-> Constant only is passed to batch as%1
, not%2
[Product Name] Constant [Product Code] [UndeclaredVariable123]
-> Constant only is passed to batch as%1
$[Product Code]
->$
only is passed to batch as%1
The 5th example shows that variables are ignored somehow if the constant is bumped to position 1.
First of all why you are adding $?
Parameters are defined in square brackets.
Set [ProductCode] or [PRODUCTCODE]
It should work, all vs arguments are one word, they do not have spaces an there is no $ sign.
Also have a look here, http://www.gogototo.com/how-to-add-a-uninstall-option-in-visual-studio-setup-project-without-writing-code.html
精彩评论