inno-setupshortcut-file

Rename existing shortcut with Inno Setup


I need to change the name of desktop application shortcut when I publish the next release of the application. I am updating my Inno Setup configuration file and I generated a new shortcut with the new name but the old shortcut is not updated or deleted.

Can I use some task or function to do it?

This my current configuration for shortcut icon.

[Tasks]
Name: "desktopicon"; Description: "{cm:CreateDesktopIcon}"; \
    GroupDescription: "{cm:AdditionalIcons}"; Flags: unchecked

...

[Icons]
Name: "{group}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"
Name: "{group}\{cm:UninstallProgram,{#MyAppName}}"; Filename: "{uninstallexe}"
Name: "{commondesktop}\{#MyAppName}"; Filename: "{app}\{#MyAppExeName}"; \
    Tasks: desktopicon

Solution

  • Use [InstallDelete] section entry to delete the unwanted/old shortcut/file:

    [Icons]
    Name: "{commondesktop}\New Shortcut"; Filename: "{app}\{#MyAppExeName}"; \
        Tasks: desktopicon
    
    [InstallDelete]
    Type: files; Name: "{commondesktop}\Old Shortcut.lnk"