NSIS卸载程序不支持';我不能正常工作

NSIS卸载程序不支持';我不能正常工作,nsis,Nsis,我正在使用NSIS安装程序脚本为我的应用程序开发一个安装程序,我面临的问题是,如果我在不同的文件夹中安装同一个应用程序,并且如果我在我首先安装的文件夹中使用uninstall.exe,它将安装最后安装的应用程序,实际上,这两个uninstall.exe都将指向上次安装的位置 以下是我制作卸载密钥的方式: ' ; Write the uninstall keys for Windows WriteRegStr HKLM Software\Microsoft\Windows\CurrentVersi

我正在使用NSIS安装程序脚本为我的应用程序开发一个安装程序,我面临的问题是,如果我在不同的文件夹中安装同一个应用程序,并且如果我在我首先安装的文件夹中使用uninstall.exe,它将安装最后安装的应用程序,实际上,这两个uninstall.exe都将指向上次安装的位置

以下是我制作卸载密钥的方式:

' ; Write the uninstall keys for Windows
WriteRegStr HKLM Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANY}${APPNAME}" "DisplayName" "${APPNAME} (Remove only)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${COMPANY} ${APPNAME}" "UninstallString" '"$INSTDIR\uninstall.exe"''
所需的行为是,每个“uninstall.exe”都应该指向它所属的安装文件夹。我知道有一个类似的问题,但对我没有任何帮助。()
非常感谢您提供的任何帮助/想法。

如果您希望允许多次安装,则每次安装都必须使用唯一的卸载密钥名:

...
Page Directory
Page InstFiles

!include LogicLib.nsh

Section
SetOutPath $InstDir
System::Call 'OLE32::CoCreateGuid(g.r1)' ; Generate a new GUID for this install
WriteUninstaller "$InstDir\Uninst.exe"
FileOpen $0 "$InstDir\Uninst.exe" a
${If} $0 <> 0
    FileSeek $0 0 END
    FileWrite $0 $1 ; Save the GUID in the uninstaller
    FileClose $0
${EndIf}
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp_$1" "DisplayName" "${APPNAME} (Remove only)"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp_$1" "UninstallString" '"$InstDir\Uninst.exe"'
File "MyApp.exe"
SectionEnd

Section Uninstall
FileOpen $0 "$ExePath" r
${If} $0 <> 0
    FileSeek $0 -38 END
    FileRead $0 $1 38
    FileClose $0
    ${If} $1 != ""
        DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp_$1"
    ${EndIf}
${EndIf}
Delete "$InstDir\Uninst.exe"
Delete "$InstDir\MyApp.exe"
RMDir $InstDir
SectionEnd
。。。
页面目录
页面文件
!包括LogicLib.nsh
部分
SetOutPath$InstDir
系统::调用“OLE32::CoCreateGuid(g.r1)”;为此安装生成新GUID
WriteUninstaller“$InstDir\Uninst.exe”
文件打开$0“$InstDir\Uninst.exe”a
${If}$0
文件查找$0结束
文件写入$0$1;在卸载程序中保存GUID
文件关闭$0
${EndIf}
WriteRegStr HKLM“Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp_$1”“DisplayName”“${APPNAME}(仅删除)”
WriteRegStr HKLM“Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp_U$1”“UninstallString”“$InstDir\Uninst.exe”
文件“MyApp.exe”
分段结束
第节卸载
文件打开$0“$ExePath”r
${If}$0
文件搜索$0-38结束
文件读取$0$1 38
文件关闭$0
${If}$1!=""
DeleteRegKey HKLM“软件\Microsoft\Windows\CurrentVersion\Uninstall\MyApp\u1”
${EndIf}
${EndIf}
删除“$InstDir\Uninst.exe”
删除“$InstDir\MyApp.exe”
RMDir$InstDir
分段结束

感谢您提出的解决方案,我有一个问题,它是什么意思
${If}$0文件查看$0-38结束文件读取$0$1 38文件关闭$0${If}$1!=“DeleteRegKey HKLM”Software\Microsoft\Windows\CurrentVersion\Uninstall\MyApp_$1“${EndIf}${EndIf}
我不理解“38”。谢谢,很抱歉出现了不好的缩进。