2012-09-02 3 views
0

NSIS와 아래 코드를 사용하여 설치 프로그램을 만듭니다. 설치 프로그램이 성공적으로 생성되었지만 PC에 프로그램을 설치할 때 제거 프로그램이 처음 insatllation 중에 생성되지는 않지만 다시 설치할 때 제거 프로그램이 성공적으로 작성되었습니다> PLZ 도움말은 무엇이 있습니까? 내 nsi 스크립트 :제거 프로그램을 만드는 중 오류가 발생했습니다.

# 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 

답변

1

WriteUninstaller으로 전화하기 전에 SetOutPath $INSTDIR을 넣으십시오.

당신은 RequestExecutionLevel user을 사용하고 $ 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 
+0

답의 첫 번째 줄은 내 문제를 해결했다. Idon't는 왜 RequestExecutionLevel 사용자와 물건에 관해 나머지가 나의 문제와 함께 어떤 relattion도 품는 지에 관해 게시해라. 어쨌든 제안에 대한 고맙습니다 – user1154781

+0

Anders가 "InstallDir $ PROGRAMFILES \ NepHotel"에 대해 이야기하고있었습니다. 사용자가이 디렉토리에 쓸 수 없기 때문에 관리자 권한이 필요하므로 간단한 관리자 권한 검사를 제안하므로 오류가 발생할 수 있습니다. – Slappy

관련 문제