繁体   English   中英

我如何制作可以多次安装的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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM