How can I remove a desktop shortcut by Innosetup? It's created by previous version and not needed anymore. I tried delete it in [InstallDelete]
[InstallDelete]
Type: files; Name: {userdesktop}\Shortcut Name
and delete the file in "ssInstall" of CurStepChanged event handler
DeleteFile(ExpandConstant('{userdesktop}\Shortcut Name'));
But they don't work. Any suggestion is appreciated!
To remove shortcuts from your computer's desktop, just right-click on them and select "Delete" or "Move to Trash." You can also use the Delete key on your keyboard, or drag the shortcuts to the trash. Removing a shortcut from your desktop won't delete the app or folder that it's connected to.
If you want to know how to remove shortcuts from the desktop in Windows 10 and Windows 11 using your cursor, you can right-click or press-and-hold on an icon to open a contextual menu. Then, click or tap on Delete if you're using Windows 10.
As you know the application icon is built into the .exe file. The Inno Setup cannot modify the .exe files. And there's no other way to override the application icon by an external one. You have to edit the .exe file yourself, before building the installer.
Either option will work, but there are a couple of considerations.
1) You'll either need to use {userdesktop} or {commondesktop} depending on whether the shortcut was installed for a specific user or for all users.
2) You'll need to make sure to add the .lnk extension to the shortcut name.
So this will probably work:
DeleteFile(ExpandConstant('{userdesktop}\Shortcut Name.lnk'));
DeleteFile(ExpandConstant('{commondesktop}\Shortcut Name.lnk'));
or
[InstallDelete]
Type: files; Name: "{userdesktop}\Shortcut Name.lnk"
Type: files; Name: "{commondesktop}\Shortcut Name.lnk"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With