使用inno setup卸载默认图标

时间:2013-04-05 23:31:11

标签: icons inno-setup uninstall

我正在使用Inno安装程序向Start Menu Foulder添加卸载图标。

使用Inno安装脚本向导(示例我的程序),有一个默认的卸载图标enter image description here

这是示例代码。

; 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

1 个答案:

答案 0 :(得分:9)

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

[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等多次安装;自定义代码功能)可能会很棘手