如何制作可以多次安装的 NSIS 安装程序?
how can I make a NSIS installer that can be installed multiple times?
我有一个应用程序可以由同一用户在同一台计算机上多次安装,并且根据在其中所做的设置而采取不同的操作。
我如何制作一个允许多次安装同一个应用程序的安装程序?默认情况下,我制作的基本脚本允许我在不同的文件夹中安装多次,但在控制面板中我只能看到要卸载的最后一个版本(我想这是因为 InstallDirRegKey)。
这是一个相当奇怪的要求,大多数应用程序不是这样工作的,只是在控制面板中显示最后安装的实例,因为每次安装时注册表中的条目都会被覆盖。
要在控制面板中显示多个条目,您需要为注册表中的每个卸载条目使用唯一的键名:
Var InstallId
RequestExecutionLevel user
Section
System::Call 'OLE32::CoCreateGuid(&g16.s)'
Pop $InstallId
SetOutPath "$InstDir"
WriteIniStr "$InstDir\Uninst.ini" "Setup" "InstallId" $InstallId ; Store the id somewhere so we know which registry key to delete
WriteUninstaller "$InstDir\Uninst.exe"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall$InstallId" DisplayName "$(^Name) ($InstDir)"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall$InstallId" UninstallString '"$InstDir\Uninst.exe"'
SectionEnd
Section Uninstall
ReadIniStr $InstallId "$InstDir\Uninst.ini" "Setup" "InstallId"
StrCmp $InstallId "" 0 +2
StrCpy $InstallId "$(^Name):BadInstallId" ; Set to some invalid id so we don't delete the wrong registry key if the .ini has been corrupted
DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall$InstallId"
Delete "$InstDir\Uninst.ini"
Delete "$InstDir\Uninst.exe"
RMDir "$InstDir"
SectionEnd
我有一个应用程序可以由同一用户在同一台计算机上多次安装,并且根据在其中所做的设置而采取不同的操作。
我如何制作一个允许多次安装同一个应用程序的安装程序?默认情况下,我制作的基本脚本允许我在不同的文件夹中安装多次,但在控制面板中我只能看到要卸载的最后一个版本(我想这是因为 InstallDirRegKey)。
这是一个相当奇怪的要求,大多数应用程序不是这样工作的,只是在控制面板中显示最后安装的实例,因为每次安装时注册表中的条目都会被覆盖。
要在控制面板中显示多个条目,您需要为注册表中的每个卸载条目使用唯一的键名:
Var InstallId
RequestExecutionLevel user
Section
System::Call 'OLE32::CoCreateGuid(&g16.s)'
Pop $InstallId
SetOutPath "$InstDir"
WriteIniStr "$InstDir\Uninst.ini" "Setup" "InstallId" $InstallId ; Store the id somewhere so we know which registry key to delete
WriteUninstaller "$InstDir\Uninst.exe"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall$InstallId" DisplayName "$(^Name) ($InstDir)"
WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall$InstallId" UninstallString '"$InstDir\Uninst.exe"'
SectionEnd
Section Uninstall
ReadIniStr $InstallId "$InstDir\Uninst.ini" "Setup" "InstallId"
StrCmp $InstallId "" 0 +2
StrCpy $InstallId "$(^Name):BadInstallId" ; Set to some invalid id so we don't delete the wrong registry key if the .ini has been corrupted
DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall$InstallId"
Delete "$InstDir\Uninst.ini"
Delete "$InstDir\Uninst.exe"
RMDir "$InstDir"
SectionEnd