使用 inno setup 卸载默认图标

Posted

技术标签:

【中文标题】使用 inno setup 卸载默认图标【英文标题】:using inno setup uninstall default icon 【发布时间】:2013-03-28 12:51:00 【问题描述】:

我正在使用 Inno 安装程序将卸载图标添加到“开始”菜单 Foulder。

使用Inno Setup Script Wizard(例如我的程序),有一个默认的卸载图标

这是示例代码。

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "My Program"
#define MyAppVersion "1.5"
#define MyAppPublisher "My Company, Inc."
#define MyAppURL "http://www.example.com/"
#define MyAppExeName "MyProg.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId=9BBC9685-FB4E-4BF1-B2B4-07A46B467911
AppName=#MyAppName
AppVersion=#MyAppVersion
;AppVerName=#MyAppName #MyAppVersion
AppPublisher=#MyAppPublisher
AppPublisherURL=#MyAppURL
AppSupportURL=#MyAppURL
AppUpdatesURL=#MyAppURL
DefaultDirName=pf\#MyAppName
DefaultGroupName=#MyAppName
AllowNoIcons=yes
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"

[Tasks]
Name: "desktopicon"; Description: "cm:CreateDesktopIcon"; GroupDescription: "cm:AdditionalIcons"; Flags: unchecked
Name: "quicklaunchicon"; Description: "cm:CreateQuickLaunchIcon"; GroupDescription: "cm:AdditionalIcons"; Flags: unchecked; OnlyBelowVersion: 0,6.1

[Files]
Source: "C:\Program Files (x86)\Inno Setup 5\Examples\MyProg.exe"; DestDir: "app"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "group\#MyAppName"; Filename: "app\#MyAppExeName"
Name: "group\cm:ProgramOnTheWeb,#MyAppName"; Filename: "#MyAppURL"
Name: "group\cm:UninstallProgram,#MyAppName"; Filename: "uninstallexe"
Name: "commondesktop\#MyAppName"; Filename: "app\#MyAppExeName"; Tasks: desktopicon
Name: "userappdata\Microsoft\Internet Explorer\Quick Launch\#MyAppName"; Filename: "app\#MyAppExeName"; Tasks: quicklaunchicon

[Run]
Filename: "app\#MyAppExeName"; Description: "cm:LaunchProgram,#StringChange(MyAppName, '&', '&&')"; Flags: nowait postinstall skipifsilent

我希望在我的软件中使用相同的卸载默认图标,以避免从互联网下载图标或创建我自己的图标。

我的 inno 设置软件的代码如下。使用此代码,卸载图标与 .exe 的图标相同。

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Remove xyz-duplicate LiDAR points"
#define MyAppVersion "0.2 Beta"
#define MyAppExeName "remove_duplicate_xyz_executable_project.exe"

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId=73F937B9-0CD9-44F1-B07E-17CD2399EE13
AppName=#MyAppName
AppVersion=#MyAppVersion
;AppVerName=#MyAppName #MyAppVersion
DefaultDirName=pf\#MyAppName
DefaultGroupName=#MyAppName
AllowNoIcons=yes
OutputBaseFilename=Remove xyz-duplicate LiDAR points
SetupIconFile=C:\PythonScript\Script_fun\Remove_duplicate_xyz\LiDAR_Remove_xyz_Duplicate_Point_executable_project\iconRemoveduplicate_two_80res_small.ico
Compression=lzma
SolidCompression=yes

[Languages]
Name: "english"; MessagesFile: "compiler:Default.isl"
Name: "brazilianportuguese"; MessagesFile: "compiler:Languages\BrazilianPortuguese.isl"
Name: "danish"; MessagesFile: "compiler:Languages\Danish.isl"
Name: "french"; MessagesFile: "compiler:Languages\French.isl"
Name: "german"; MessagesFile: "compiler:Languages\German.isl"
Name: "italian"; MessagesFile: "compiler:Languages\Italian.isl"
Name: "norwegian"; MessagesFile: "compiler:Languages\Norwegian.isl"
Name: "russian"; MessagesFile: "compiler:Languages\Russian.isl"
Name: "spanish"; MessagesFile: "compiler:Languages\Spanish.isl"

[Tasks]
Name: "desktopicon"; Description: "cm:CreateDesktopIcon"; GroupDescription: "cm:AdditionalIcons"; Flags: unchecked
Name: "quicklaunchicon"; Description: "cm:CreateQuickLaunchIcon"; GroupDescription: "cm:AdditionalIcons"; Flags: unchecked; OnlyBelowVersion: 0,6.1

[Files]
Source: "C:\Program Files (x86)\Inno Setup 5\Examples\MyProg.exe"; DestDir: "app"; Flags: ignoreversion
Source: "C:\PythonScript\Script_fun\Remove_duplicate_xyz\LiDAR_Remove_xyz_Duplicate_Point_executable_project\dist\_ctypes.pyd"; DestDir: "app"; Flags: ignoreversion
Source: "C:\PythonScript\Script_fun\Remove_duplicate_xyz\LiDAR_Remove_xyz_Duplicate_Point_executable_project\dist\_hashlib.pyd"; DestDir: "app"; Flags: ignoreversion
Source: "C:\PythonScript\Script_fun\Remove_duplicate_xyz\LiDAR_Remove_xyz_Duplicate_Point_executable_project\dist\_socket.pyd"; DestDir: "app"; Flags: ignoreversion
Source: "C:\PythonScript\Script_fun\Remove_duplicate_xyz\LiDAR_Remove_xyz_Duplicate_Point_executable_project\dist\_ssl.pyd"; DestDir: "app"; Flags: ignoreversion
Source: "C:\PythonScript\Script_fun\Remove_duplicate_xyz\LiDAR_Remove_xyz_Duplicate_Point_executable_project\dist\bz2.pyd"; DestDir: "app"; Flags: ignoreversion
Source: "C:\PythonScript\Script_fun\Remove_duplicate_xyz\LiDAR_Remove_xyz_Duplicate_Point_executable_project\dist\library.zip"; DestDir: "app"; Flags: ignoreversion
Source: "C:\PythonScript\Script_fun\Remove_duplicate_xyz\LiDAR_Remove_xyz_Duplicate_Point_executable_project\dist\python27.dll"; DestDir: "app"; Flags: ignoreversion
Source: "C:\PythonScript\Script_fun\Remove_duplicate_xyz\LiDAR_Remove_xyz_Duplicate_Point_executable_project\dist\remove_duplicate_xyz_executable_project.exe"; DestDir: "app"; Flags: ignoreversion
Source: "C:\PythonScript\Script_fun\Remove_duplicate_xyz\LiDAR_Remove_xyz_Duplicate_Point_executable_project\dist\select.pyd"; DestDir: "app"; Flags: ignoreversion
Source: "C:\PythonScript\Script_fun\Remove_duplicate_xyz\LiDAR_Remove_xyz_Duplicate_Point_executable_project\dist\unicodedata.pyd"; DestDir: "app"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

[Icons]
Name: "group\#MyAppName"; Filename: "app\#MyAppExeName"
Name: "group\cm:UninstallProgram,#MyAppName"; Filename: "uninstallexe"
Name: "commondesktop\#MyAppName"; Filename: "app\#MyAppExeName"; Tasks: desktopicon
Name: "userappdata\Microsoft\Internet Explorer\Quick Launch\#MyAppName"; Filename: "app\#MyAppExeName"; Tasks: quicklaunchicon

[Run]
Filename: "app\#MyAppExeName"; Description: "cm:LaunchProgram,#StringChange(MyAppName, '&', '&&')"; Flags: nowait postinstall skipifsilent

【问题讨论】:

这是因为您使用图标设置文件SetupIconFile=C:\PythonScript\Script_fun\Remove_duplicate_xyz\LiDAR_Remove_xyz_Duplicate_Point_executable_project\iconRemoveduplicate_two_80res_small.ico。如果你想要通用图标,你应该为安装和卸载都使用通用,或者如果你为安装指定图标,你应该为卸载指定图标以及UninstallDisplayIcon= 谢谢 RobeN。我真的是 Inno steup 的初学者,目前尚不清楚如何解决这个问题。我希望使用图标“iconRemoveduplicate_two_80res_small.ico”进行设置,使用默认图标进行卸载。问你正确的代码行有问题吗?提前致谢 @RobeN 但如果我使用 UninstallDisplayIcon 指定卸载图标,我是否需要一个文件 *.ico? 是的,Icon lub Exe 里面有图标。如果您为安装程序设置图标,默认情况下它会被卸载程序继承,除非您为卸载程序指定不同的图标。 @RobeN 以及为什么使用 inno 设置默认示例(MyAppName“我的程序”)我有一个卸载图标而没有设置图标 *.ico 文件?见上面的例子 【参考方案1】:

如果您设置SetupIconFile,则卸载 Exe 文件(例如 unins000.exe)将实现完全相同的图标。覆盖此图标显示的一种方法是在控制面板添加/删除列表的[Setup] 部分中设置自定义UninstallDisplayIcon,在桌面、开始菜单等上设置快捷方式的[Icons] 部分中的IconFileName。在这两种情况下,您必须有您的自定义图标文件,该文件必须与您的应用程序一起安装。

[Setup]
SetupIconFile=C:\mysourcedir\mysetup.ico
UninstallDisplayIcon=app\myuninstall.ico 
                        //overrides icon on Add/Remove List in Control Panel

[Files]
Source: "C:\mysourcedir\myuninstall.ico"; DestDir: "app"

[Icons]
Name: "group\cm:UninstallProgram,#MyAppName"; Filename: "uninstallexe";
 IconFilename: "app\myuninstall.ico" 
                       //overrides icon in Start Menu shortcut

第二个是预编译 unins000.exe 并实现特定图标。虽然在某些情况下可能会很棘手(使用 unins001、unins002 等进行多次安装;自定义代码功能)

【讨论】:

以上是关于使用 inno setup 卸载默认图标的主要内容,如果未能解决你的问题,请参考以下文章

Inno Setup5 如何更改卸载图标(我做出来的安装程序和卸载的一样)我想把卸载图标换成别的。

如何更改Inno Setup生成的卸载程序的名字与图标

更改 Inno Setup 卸载程序的默认名称以避免命名冲突

Inno Setup:无需管理员权限即可卸载

inno setup打包的安装文件更换位置后图标改变了

inno setup 之Deltree 用法