立即注册 登录
总裁社区 返回首页

飞鹰科技 https://www.sysceo.com/forum/?51833 [收藏] [复制] [分享] [RSS]

日志

Inno Setup 系列之自定义卸载文件名称的脚本

已有 173 次阅读2019-8-21 16:54

该示例脚本显示如何自定义卸载文件的名称(默认为unins000.exe,unins001.exe等等)。

[setup]
AppName=自定义卸载文件名示例程序
AppVerName=自定义卸载文件名示例程序 1.0
DefaultDirName={pf}\自定义卸载文件名示例程序
DefaultGroupName=自定义卸载文件名示例程序

[files]
Source: "MyTest.exe"; DestDir: "{app}"
Source: "Readme.txt"; DestDir: "{app}"

[code]
procedure CurStepChanged(CurStep: TSetupStep);
var
uninspath, uninsname, NewUninsName, MyAppName: string;
begin
if CurStep=ssDone then
begin
// 指定新的卸载文件名(不包含扩展名),请相应修改!
NewUninsName := '卸载';
// 应用程序名称,与 [Setup] 段的 AppName 必须一致,请相应修改!
MyAppName := '自定义卸载文件名示例程序';
// 以下重命名卸载文件
uninspath:= ExtractFilePath(ExpandConstant('{uninstallexe}'));
uninsname:= Copy(ExtractFileName(ExpandConstant('{uninstallexe}')),1,8);
RenameFile(uninspath + uninsname + '.exe', uninspath + NewUninsName + '.exe');
RenameFile(uninspath + uninsname + '.dat', uninspath + NewUninsName + '.dat');
// 以下修改相应的注册表内容
if RegKeyExists(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + MyAppName + '_is1') then
begin
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + MyAppName + '_is1', 'UninstallString', '"' + uninspath + NewUninsName + '.exe"');
RegWriteStringValue(HKEY_LOCAL_MACHINE, 'SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\' + MyAppName + '_is1', 'QuietUninstallString', '"' + uninspath + NewUninsName + '.exe" /silent');
end;
end;
end;


路过

鸡蛋

鲜花

握手

雷人

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 立即注册