如何通过Innosetup删除桌面快捷方式

tru*_*ger 21 inno-setup desktop-shortcut

如何通过Innosetup删除桌面快捷方式?它是由以前的版本创建的,不再需要了.我尝试在[InstallDelete]中删除它

[InstallDelete]
Type: files; Name: {userdesktop}\Shortcut Name
Run Code Online (Sandbox Code Playgroud)

并删除CurStepChanged事件处理程序的"ssInstall"中的文件

DeleteFile(ExpandConstant('{userdesktop}\Shortcut Name'));
Run Code Online (Sandbox Code Playgroud)

但它们不起作用.任何建议表示赞赏!

Ger*_*ald 29

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'));
Run Code Online (Sandbox Code Playgroud)

or

[InstallDelete]
Type: files; Name: "{userdesktop}\Shortcut Name.lnk"
Type: files; Name: "{commondesktop}\Shortcut Name.lnk"
Run Code Online (Sandbox Code Playgroud)

  • 虽然我安装了名称为“{commondesktop}\...”的链接,但上述删除它的解决方案对我不起作用,我不得不退回到类型:文件;名称:“C:\Users\Public\ Desktop\My App.lnk”作为解决方法。 (2认同)