tags:

views:

125

answers:

2

Is there any way to tell NSIS not to overwrite my start menu shortcut. The reason I don't want it to overwrite is so the user's command line options aren't cleared when they upgrade to a new version. I've tried this to no avail:

Section -AdditionalIcons
  SetOverwrite off
  CreateDirectory "${START_MENU_DIR}"
  CreateShortCut  "${START_MENU_LNK}" "$INSTDIR\${PRODUCT_NAME}.exe"
SectionEnd
+2  A: 

Why can't you just check with IfFileExists ?

If you wanted to go all out, you could update the path and working dir, but leave the parameters and icon in place, but to do that you would have to call the IShellLink COM interface on your own (With the system plugin or a custom plugin/app)

Anders
Yes thank you. I actually realized that last night. It works great. I put some example code as another answer.
Jesse
+1  A: 

Here is an example that works:

Section -AdditionalIcons

  CreateDirectory "${START_MENU_DIR}"
  IfFileExists "${START_MENU_LNK}" SkipShortcut
  CreateShortCut "${START_MENU_LNK}" "$INSTDIR\${PRODUCT_NAME}.exe"

SkipShortcut:

SectionEnd
Jesse