Nsis 创建卸载程序时出错
我使用NSIS和下面给出的代码创建了一个安装程序。安装程序已成功创建,但当我在pc中安装程序时,卸载程序在第一次安装期间未创建,但当我再次安装时,卸载程序已成功创建>我可以做什么plz帮助。。。 我的nsi脚本:Nsis 创建卸载程序时出错,nsis,uninstallation,Nsis,Uninstallation,我使用NSIS和下面给出的代码创建了一个安装程序。安装程序已成功创建,但当我在pc中安装程序时,卸载程序在第一次安装期间未创建,但当我再次安装时,卸载程序已成功创建>我可以做什么plz帮助。。。 我的nsi脚本: # declare name of installer file !define PRODUCT_NAME "NepHotel" Name "NepHotel" outfile "NepHotel_setup.exe" InstallDir $PROGRAMFILES\NepHot
# declare name of installer file
!define PRODUCT_NAME "NepHotel"
Name "NepHotel"
outfile "NepHotel_setup.exe"
InstallDir $PROGRAMFILES\NepHotel
RequestExecutionLevel user
Page directory
Page instfiles
# open section
section ""
CreateShortCut "$DESKTOP\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe" ""
;create start-menu items
CreateDirectory "$SMPROGRAMS\NepHotel"
CreateShortCut "$SMPROGRAMS\NepHotel\${PRODUCT_NAME}.lnk" "$INSTDIR\${PRODUCT_NAME}.exe" "" "$INSTDIR\${PRODUCT_NAME}.exe" 0
CreateShortCut "$SMPROGRAMS\NepHotel\Readme.lnk" "$INSTDIR\user.props" "" "$INSTDIR\user.props" 0
CreateShortCut "$SMPROGRAMS\NepHotel\uninstall.lnk" "$INSTDIR\uninstall.exe" 1
;write uninstall information to the registry
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NepHotel" \
"DisplayName" "${PRODUCT_NAME}"
WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\NepHotel" \
"UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
WriteUninstaller "$INSTDIR\Uninstall.exe"
SetOutPath $INSTDIR
File NepHotel.exe
File user.props
# end the section
sectionEnd
;Uninstaller Section
Section "Uninstall"
;Delete Files
RMDir /r "$INSTDIR\*.*"
;Remove the installation directory
RMDir "$INSTDIR"
;Delete Start Menu Shortcuts
Delete "$DESKTOP\${PRODUCT_NAME}.lnk"
Delete "$SMPROGRAMS\${PRODUCT_NAME}\*.*"
RmDir "$SMPROGRAMS\${PRODUCT_NAME}"
;Delete Uninstaller And Unistall Registry Entries
enter code here DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\${PRODUCT_NAME}"
DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall \${PRODUCT_NAME}"
SectionEnd
Function .onInstSuccess
MessageBox MB_OK "You have successfully installed ${PRODUCT_NAME}. Use the desktop icon to start the program."
FunctionEnd
将
SetOutPath$INSTDIR
放在调用WriteUninstaller
之前
您不能使用RequestExecutionLevel用户
然后安装到$Programfiles/HKLM,您需要请求管理员权限:
Outfile RequireAdmin.exe
; BEGIN 8< 8< 8< 8< 8< 8< 8< 8<
RequestExecutionLevel admin ;Require admin rights on NT6+ (When UAC is turned on)
!include LogicLib.nsh
Function .onInit
UserInfo::GetAccountType
pop $0
${If} $0 != "admin" ;Require admin rights on NT4+
MessageBox mb_iconstop "Administrator rights required!"
SetErrorLevel 740 ;ERROR_ELEVATION_REQUIRED
Quit
${EndIf}
FunctionEnd
; END >8 >8 >8 >8 >8 >8 >8 >8
Page InstFiles
Section
SectionEnd
Outfile RequireAdmin.exe
; 开始8<8<8<8<8<8<8<8<8<8<
RequestExecutionLevel管理员;需要NT6+上的管理员权限(当UAC打开时)
!包括LogicLib.nsh
函数。onInit
UserInfo::GetAccountType
流行音乐$0
${If}$0!=“管理”;需要NT4上的管理员权限+
MessageBox mb_iconstop“需要管理员权限!”
设置错误级别740;错误\u需要仰角\u
退出
${EndIf}
功能端
; 结束>8>8>8>8>8>8>8>8>8>8>8
页面文件
部分
分段结束
你回答的第一行解决了我的问题。我不知道你为什么要发布关于RequestExecutionLevel用户的其他信息,这些信息与我的问题有关系吗。。???无论如何,thanx for suggestionAnders谈论的是“InstallDir$PROGRAMFILES\NepHotel”:这可能会导致错误,因为用户无法写入此目录-需要管理员权限,因此他建议您进行简单的管理员权限检查。