2013-08-06 89 views
1

我是NSIS的新手,但是我想在安装新版本的同时对已安装的旧版本进行检查。我完全像我在这里找到的那​​样 - http://nsis.sourceforge.net/Auto-uninstall_old_before_installing_new但是因为我需要检查是否安装了旧版本才能正确卸载,所以我将InstallLocation注册表值添加到安装进度中。在安装新版本之前卸载旧版本

如果我使用ExecWait'$ R0 _?= $ INSTDIR'并且旧版本的安装文件夹与INSTDIR相同,则一切正常。但是,如果我使用ExecWait'$ R0 _?= $ R1',它会给我NSIS安装程序错误,但我无法找到问题出在哪里,我做错了什么?

有人可以帮忙吗? 感谢


登记由该补充道:


WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${AppName}" "InstallLocation" '"$INSTDIR"' 

的功能代码:


ReadRegStr $R0 HKLM \ 
"Software\Microsoft\Windows\CurrentVersion\Uninstall\${AppName}" \ 
"UninstallString" 

    StrCmp $R0 "" done 

MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \ 
    "${AppName} is already installed. $\n$\nClick OK to remove the \ 
    previous version or Cancel to cancel the installation." \ 
IDOK uninst 
Abort 

;Run the uninstaller 
uninst: 
    ReadRegStr $R1 HKLM \ 
    "Software\Microsoft\Windows\CurrentVersion\Uninstall\${AppName}" \ 
    "InstallLocation" 

    ClearErrors 
    HideWindow 
    ClearErrors 
    ExecWait '$R0 _?=$R1' 
    BringToFront 

done: 
functionEnd 

回答

2

你正在写引号,不要在InstallLocation路径不这样做或者在执行安装程序之前剥去代码中的引号...

+0

对不起,但您能告诉我究竟应该在哪里删除这些引号吗?我不明白。 – madleeen

+0

'“$ INSTDIR”',无论是在WriteRegStr调用中,还是在ReadRegStr – Anders

+0

之后使用strcmp + strcpy很酷,谢谢,它工作正常。 – madleeen

相关问题