NSIS打包基础脚本

!define PRODUCT_NAME "Lenovo Moto Smart Assistant"
!define PRODUCT_VERSION "3.9.7.13"
!define PRODUCT_PUBLISHER "Lenovo"
!define PRODUCT_LINK_NAME "Lenovo Moto Smart Assistant.lnk"
!define PRODUCT_MAIN_EXE "Lenovo Moto Smart Assistant.exe"
#!define PRODUCT_MAIN_EXE "WpfApplication7.exe"
!define PRODUCT_UNINSTALL_SURVEY "Survey\UninstallSurvey.exe"
!define PRODUCT_WEB_SITE "http://www.lenovo.com"
!define PRODUCT_TEMP "$APPDATA\lmsa"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\Lenovo Moto Smart Assistant.exe"
!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
!define PRODUCT_WEBBROWSER_IE_VERSION "Software\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION"
!define PRODUCT_UNINST_ROOT_KEY "HKLM"
!define HKEY_LOCAL_MACHINE 0x80000002

SetCompressor lzma

; MUI 1.67 compatible ------
!include "MUI.nsh"
!include "LogicLib.nsh"
!include "FileFunc.nsh"
!include "NSISList.nsh"

; MUI Settings
!define MUI_ABORTWARNING
!define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\orange-install.ico"
!define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\orange-uninstall.ico"

; Language Selection Dialog Settings
!define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_LANGDLL_REGISTRY_KEY "${PRODUCT_UNINST_KEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"

; These indented statements modify settings for MUI_PAGE_FINISH
!define MUI_FINISHPAGE_NOAUTOCLOSE
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_CHECKED
!define MUI_FINISHPAGE_RUN_TEXT "Launch the program"
!define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink"
;!define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
;!define MUI_FINISHPAGE_SHOWREADME $INSTDIR\readme.txt

; Welcome page
!insertmacro MUI_PAGE_WELCOME
; License page
#!define MUI_LICENSEPAGE_CHECKBOX
!define MUI_LICENSEPAGE_RADIOBUTTONS
!insertmacro MUI_PAGE_LICENSE ".\lmsa\Installation\Resources\license.rtf"
; Directory page
!insertmacro MUI_PAGE_DIRECTORY
; Instfiles page
!insertmacro MUI_PAGE_INSTFILES
; Finish page
!insertmacro MUI_PAGE_FINISH

; Uninstaller pages
!insertmacro MUI_UNPAGE_INSTFILES

; Language files
!insertmacro MUI_LANGUAGE "English"
#!insertmacro MUI_LANGUAGE "SimpChinese"

; Reserve files
!insertmacro MUI_RESERVEFILE_INSTALLOPTIONS

; MUI end ------

Name "${PRODUCT_NAME}"
OutFile "${PRODUCT_NAME}-${PRODUCT_VERSION}.exe"
InstallDir "$PROGRAMFILES\Lenovo Moto Smart Assistant"
InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
#RequestExecutionLevel admin
ShowInstDetails show
ShowUnInstDetails show
#BrandingText "Lenovo"
BrandingText " "
XPStyle on

!macro KillProcMacro un
  Function ${un}KillProcFunc
    StrCpy $0 "${PRODUCT_MAIN_EXE}"
    KillProc::FindProcesses
    ${If} $1 = 0
    ${AndIf} $0 > 0
        MessageBox MB_ICONQUESTION|MB_OKCANCEL|MB_DEFBUTTON2 "The ${PRODUCT_MAIN_EXE} is running, whether to continue uninstalling?" IDOK done_uninstall
        Abort
            
        done_uninstall:
            StrCpy $0 "${PRODUCT_MAIN_EXE}"
            KillProc::KillProcesses
    ${EndIf}
  FunctionEnd
!macroend
!insertmacro KillProcMacro ""
!insertmacro KillProcMacro "un."

Function CheckAndDownloadDotNet45
    Var /GLOBAL dotNET45IsThere
    Var /GLOBAL dotNET_CMD_LINE
    Var /GLOBAL EXIT_CODE

    ReadRegDWORD $dotNET45IsThere HKLM "SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" "Release"
    IntCmp $dotNET45IsThere 378389 is_equal is_less is_greater
    is_equal:
        Goto done_compare_not_needed
    is_greater:
        Goto done_compare_not_needed
    is_less:
        Goto done_compare_exit
        #Goto done_compare_needed
    done_compare_exit:
        MessageBox MB_OK|MB_ICONEXCLAMATION "Your computer does not have .NET Framework 4.5, please install it first."
        Abort
    done_compare_needed:
        # Microsoft Download Center EXE:
        # Web Bootstrapper: http://go.microsoft.com/fwlink/?LinkId=225704
        # Full Download: http://go.microsoft.com/fwlink/?LinkId=225702
        
        # Let's see if the user is doing a Silent install or not
        IfSilent is_quiet is_not_quiet

        is_quiet:
            StrCpy $dotNET_CMD_LINE "/q /norestart"
            Goto LookForLocalFile
        is_not_quiet:
            StrCpy $dotNET_CMD_LINE "/showrmui /passive /norestart"
            Goto LookForLocalFile

        LookForLocalFile:
            IfFileExists "$EXEPATH\components\dotNET45Full.exe" do_local_install do_network_install

            do_local_install:
                ExecWait '"$EXEPATH\components\dotNET45Full.exe" $dotNET_CMD_LINE' $EXIT_CODE
                Goto is_reboot_requested

            do_network_install:
                Var /GLOBAL dotNetDidDownload
                NSISdl::download "http://go.microsoft.com/fwlink/?LinkId=225704" "$TEMP\dotNET45Web.exe" $dotNetDidDownload

                StrCmp $dotNetDidDownload success fail
                success:
                    ExecWait '"$TEMP\dotNET45Web.exe" $dotNET_CMD_LINE' $EXIT_CODE
                    Goto is_reboot_requested

                fail:
                    MessageBox MB_OK|MB_ICONEXCLAMATION "Unable to download .NET Framework.  ${PRODUCT_NAME} will be installed, but will not function without the Framework!"
                    Goto done_dotNET_function

                is_reboot_requested:
                    ${If} $EXIT_CODE = 1641
                    ${OrIf} $EXIT_CODE = 3010
                        SetRebootFlag true
                    ${EndIf}

    done_compare_not_needed:
        Goto done_dotNET_function
    done_dotNET_function:
FunctionEnd

Function CheckSingleInstallation
    ;Single case installation
    System::Call 'kernel32::CreateMutexA(i 0, i 0, t "myMutex") i .r1 ?e'
    Pop $R0
    StrCmp $R0 0 +3
    MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is running..."
    Abort
FunctionEnd

;$var=0 Versions are equal
;$var=1 Version1 is newer
;$var=2 Version2 is newer
Function VersionCompare
    !define VersionCompare `!insertmacro VersionCompareCall`

    !macro VersionCompareCall _VER1 _VER2 _RESULT
        Push `${_VER1}`
        Push `${_VER2}`
        Call VersionCompare
        Pop ${_RESULT}
    !macroend

    Exch $1
    Exch
    Exch $0
    Exch
    Push $2
    Push $3
    Push $4
    Push $5
    Push $6
    Push $7

    begin:
    StrCpy $2 -1
    IntOp $2 $2 + 1
    StrCpy $3 $0 1 $2
    StrCmp $3 '' +2
    StrCmp $3 '.' 0 -3
    StrCpy $4 $0 $2
    IntOp $2 $2 + 1
    StrCpy $0 $0 '' $2

    StrCpy $2 -1
    IntOp $2 $2 + 1
    StrCpy $3 $1 1 $2
    StrCmp $3 '' +2
    StrCmp $3 '.' 0 -3
    StrCpy $5 $1 $2
    IntOp $2 $2 + 1
    StrCpy $1 $1 '' $2

    StrCmp $4$5 '' equal

    StrCpy $6 -1
    IntOp $6 $6 + 1
    StrCpy $3 $4 1 $6
    StrCmp $3 '0' -2
    StrCmp $3 '' 0 +2
    StrCpy $4 0

    StrCpy $7 -1
    IntOp $7 $7 + 1
    StrCpy $3 $5 1 $7
    StrCmp $3 '0' -2
    StrCmp $3 '' 0 +2
    StrCpy $5 0

    StrCmp $4 0 0 +2
    StrCmp $5 0 begin newer2
    StrCmp $5 0 newer1
    IntCmp $6 $7 0 newer1 newer2

    StrCpy $4 '1$4'
    StrCpy $5 '1$5'
    IntCmp $4 $5 begin newer2 newer1

    equal:
    StrCpy $0 0
    goto end
    newer1:
    StrCpy $0 1
    goto end
    newer2:
    StrCpy $0 2

    end:
    Pop $7
    Pop $6
    Pop $5
    Pop $4
    Pop $3
    Pop $2
    Pop $1
    Exch $0
FunctionEnd

;$R0=0 exists
;$R0=2 not exists
;$R0=other error
;$R1 Handle of the key ($0)
Function CheckRegKeyExists
    StrCpy $1 "Software\Microsoft\Windows\CurrentVersion\Uninstall\$0"
    ;Create a cache for the handle of the key
    System::Call "*(i 0) i .R0"
    Push $1
    ;Check with API, return value in $R1
    system::call 'Advapi32::RegOpenKey(i ${HKEY_LOCAL_MACHINE}, t s, i R0) .iR1'
    ;Close the handle of the key
    system::call 'Advapi32::RegCloseKey(i R0)'
    ;Free memory of $R0
    system::free $1
FunctionEnd

Function CheckInstallshieldPackage
    #Var /GLOBAL Installshield_Package_UninstallString
    Var /GLOBAL Installshield_Product_ID
    #StrCpy $Installshield_Product_ID ""
    
    ${List.Create} Product_ID_Array
    ${List.Add} Product_ID_Array "{1930BFD1-2F0A-43D9-B760-FAA2A40806DE}"
    ${List.Add} Product_ID_Array "{21E28485-F3A3-4D3E-86A3-7E17C1BAAF42}"
    ${List.Add} Product_ID_Array "{63BF7D1C-95B4-4E37-97A7-F8835B8A13D0}"
    ${List.Add} Product_ID_Array "{3E34ECBE-D771-4D2B-8BDB-F4CF0BF663D1}"
    ${List.Add} Product_ID_Array "{B72D19C8-EDA7-4C56-B8E8-EA3D35749BF4}"
    ${List.Add} Product_ID_Array "{DB16BC9B-89C2-46A5-840F-79410CAB73B1}"
    ${List.Add} Product_ID_Array "{C5E66E98-6776-477B-B0B3-B1A8372F8CC6}"
    ${List.Add} Product_ID_Array "{4EE4FC82-5245-478B-BBD2-15E977072240}"
    ${List.Add} Product_ID_Array "{4F7F8A4C-5D6E-4A4D-AD0B-8FF4964CA277}"
    ${List.Add} Product_ID_Array "{A92D6B74-8528-4284-841F-76B3D9CE478B}"
    ${List.Add} Product_ID_Array "{4226EB1C-E6C5-471F-88BC-5081A8D3FBD8}"
    #${List.Add} Product_ID_Array "{F3D02057-5B79-4AAE-A989-4EB8E71D6BEE}"
    
    ${List.All} Product_ID_Array
    Loop1:
        Pop $0
        ${If} $0 != ""
        ${AndIf} $0 != "__LAST"
            Call CheckRegKeyExists
            ${If} $R1 <> 0
                MessageBox MB_OK "TEST1"
                Goto Loop1
            ${Else}
                StrCpy $Installshield_Product_ID $0
                Call KillProcFunc
                ExecCmd::exec 'cmd /c MsiExec.exe /qb /x $Installshield_Product_ID'
            ${EndIf}
        ${EndIf}
        
        #Pop $0
        #StrCmp $0 "" +5 0
        #ReadRegDWORD $Installshield_Package_UninstallString ${PRODUCT_UNINST_ROOT_KEY} "Software\Microsoft\Windows\CurrentVersion\Uninstall\$0" "UninstallString"
        #StrCmp $Installshield_Package_UninstallString "" +3
        #StrCpy $Installshield_Product_ID $0
        #Goto +2
        #StrCmp $0 "__LAST" +3 Loop1
        
    #Call KillProcFunc
    #ExecCmd::exec 'cmd /c MsiExec.exe /qb /x $Installshield_Product_ID'
FunctionEnd

Function CheckExistsOrUpgrade
    ReadRegStr $0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion"
    ReadRegStr $R0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString"
    ${VersionCompare} $0 ${PRODUCT_VERSION} $0
    ${If} $R0 != ""
        MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
            "${PRODUCT_NAME} ${PRODUCT_VERSION} is already installed. $\n$\nClick `OK` to remove the \
            previous version or `Cancel` to cancel this upgrade." \
            IDOK continue_install
        Abort
        
        continue_install:
            ${If} $0 = 2
                WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_DIR_REGKEY}" "Upgrade" 0x1
            ${EndIf}
            
            ClearErrors
            #Exec $R0
            ExecWait '$R0 _?=$INSTDIR'
    ${EndIf}
FunctionEnd

Function .onInit
    Call CheckSingleInstallation
    Call CheckInstallshieldPackage
    Call CheckExistsOrUpgrade
    Call CheckAndDownloadDotNet45
    !insertmacro MUI_LANGDLL_DISPLAY
FunctionEnd

Function .onInstFailed
FunctionEnd

Function .onInstSuccess
    #DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
FunctionEnd

Section "MainSection" SEC01
    SetOutPath "$INSTDIR"
    SetOverwrite try
    File ".\Bin\adb.exe"
    File ".\Bin\AdbWinApi.dll"
    File ".\Bin\AdbWinUsbApi.dll"
    File ".\Bin\LibUsbDotNet.dll"
    File ".\Bin\BouncyCastle.Crypto.dll"
    File ".\Bin\Common.Logging.Core.dll"
    File ".\Bin\Common.Logging.dll"
    File ".\Bin\Common.Logging.Log4Net1215.dll"
    File ".\Bin\EntityFramework.dll"
    File ".\Bin\fastboot.exe"
    File ".\Bin\Gma.QrCodeNet.Encoding.dll"
    File ".\Bin\GoogleAnalytics.Core.dll"
    File ".\Bin\GoogleAnalytics.WPF.Managed.dll"
    File ".\Bin\Lenovo Moto Smart Assistant.exe"
    File ".\Bin\Lenovo Moto Smart Assistant.exe.config"
    File ".\Bin\lenovo.themes.generic.exe"
    File ".\Bin\Newtonsoft.Json.dll"
    File ".\Bin\Microsoft.Expression.Interactions.dll"
    File ".\Bin\System.Windows.Interactivity.dll"
    File ".\Bin\SevenZipSharp.dll"
    File ".\Bin\SharpAdbClient.dll"
    
    File ".\Bin\plugins.xml"
    File ".\Bin\download-config.xml"
    File ".\Bin\user*.xml"
    
    File ".\Bin\lenovo.mbg.service.*.dll"
    File ".\Bin\SharpVectors.*.dll"
    File ".\Bin\log4net.*"
    #File /r /x lmsa*.exe /x *.pdb /x *.nsi ".\*.*"
    CreateDirectory "$SMPROGRAMS\Lenovo"
    CreateShortCut "$SMPROGRAMS\Lenovo\${PRODUCT_LINK_NAME}" "$INSTDIR\${PRODUCT_MAIN_EXE}"
    CreateShortCut "$DESKTOP\${PRODUCT_LINK_NAME}" "$INSTDIR\${PRODUCT_MAIN_EXE}"
    
    SetOutPath "$INSTDIR\Survey"
    File ".\UninstallSurvey\UninstallSurvey\Release\UninstallSurvey.exe.*"
    
    SetOutPath "$INSTDIR\Document"
    File ".\lmsa\Installation\Resources\Document\*.*"
    
    SetOutPath "$INSTDIR\7z"
    File /r ".\Bin\7z\*.*"
    
    SetOutPath "$INSTDIR\7zSharp"
    File /r ".\Bin\7zSharp\*.*"
    
    SetOutPath "$INSTDIR\apk"
    File /r ".\Bin\apk\lmsa.apk"
    
    SetOutPath "$INSTDIR\en"
    File /r ".\Bin\en\*.*"
    
    SetOutPath "$INSTDIR\lang"
    File /r ".\lmsa\Installation\Resources\Document\lang\*.*"
    
    SetOutPath "$INSTDIR\pluginIcons"
    File /r ".\Bin\pluginIcons\*.*"
    
    SetOutPath "$INSTDIR\plugins\02928af025384c75ae055aa2d4f256c8"
    File /x "lenovo.mbg.service.framework.devicemgt.dll" \
         /x "lenovo.mbg.service.framework.lang.dll" \
         /x "lenovo.mbg.service.lmsa.hostproxy.dll" \
         /x "LibUsbDotNet.dll" \
         /x "Microsoft.Windows.Shell.dll" \
         /x "SharpAdbClient.dll" \
            ".\Bin\plugins\02928af025384c75ae055aa2d4f256c8\*.dll"
    File ".\Bin\plugins\02928af025384c75ae055aa2d4f256c8\lenovo.mbg.service.lmsa.phoneManager.exe"
    File ".\Bin\plugins\02928af025384c75ae055aa2d4f256c8\lenovo.mbg.service.lmsa.phoneManager.exe.config"
    SetOutPath "$INSTDIR\plugins\02928af025384c75ae055aa2d4f256c8\en"
    File /r ".\Bin\plugins\02928af025384c75ae055aa2d4f256c8\en\*.*"
    
    SetOutPath "$INSTDIR\plugins\310f47ad70d54880b33225d864e6fe68"
    File ".\Bin\plugins\310f47ad70d54880b33225d864e6fe68\*.dll"
    File ".\Bin\plugins\310f47ad70d54880b33225d864e6fe68\lenovo.mbg.service.lmsa.forum.exe"
    File ".\Bin\plugins\310f47ad70d54880b33225d864e6fe68\lenovo.mbg.service.lmsa.forum.exe.config"
    
    SetOutPath "$INSTDIR\plugins\8ab04aa975e34f1ca4f9dc3a81374e2c"
    File ".\lmsa\Installation\Resources\Avatar\reaper.cfg"
    File ".\lmsa\Installation\Resources\Avatar\reaper_x86_Debug_MultiByte.dll"
    File ".\lmsa\Installation\Resources\Avatar\reaper_x86_Release_MultiByte.dll"
    File /x "lenovo.mbg.service.framework.lang.dll" \
         /x "lenovo.mbg.service.lmsa.hostproxy.dll" \
            ".\Bin\plugins\8ab04aa975e34f1ca4f9dc3a81374e2c\*.dll"
    File ".\Bin\plugins\8ab04aa975e34f1ca4f9dc3a81374e2c\*.exe"
    File ".\Bin\plugins\8ab04aa975e34f1ca4f9dc3a81374e2c\*.exe.config"
    SetOutPath "$INSTDIR\plugins\8ab04aa975e34f1ca4f9dc3a81374e2c\en"
    File /r ".\Bin\plugins\8ab04aa975e34f1ca4f9dc3a81374e2c\en\*.*"
    
    SetOutPath "$INSTDIR\plugins\992e746537954a7d9ae613d5ec9bc7a6"
    File /x "lenovo.mbg.service.lmsa.hostproxy.dll" ".\Bin\plugins\992e746537954a7d9ae613d5ec9bc7a6\*.dll"
    File ".\Bin\plugins\992e746537954a7d9ae613d5ec9bc7a6\lenovo.mbg.service.lmsa.tips.exe"
    File ".\Bin\plugins\992e746537954a7d9ae613d5ec9bc7a6\lenovo.mbg.service.lmsa.tips.exe.config"
    
    SetOutPath "$INSTDIR\plugins\d7deab64b8cb4e31b600ad0d839b6d73"
    File ".\Bin\plugins\d7deab64b8cb4e31b600ad0d839b6d73\index.html"
    File ".\Bin\plugins\d7deab64b8cb4e31b600ad0d839b6d73\*.dll"
    File ".\Bin\plugins\d7deab64b8cb4e31b600ad0d839b6d73\lenovo.mbg.service.lmsa.messenger.exe"
    File ".\Bin\plugins\d7deab64b8cb4e31b600ad0d839b6d73\lenovo.mbg.service.lmsa.messenger.exe.config"
    SetOutPath "$INSTDIR\plugins\d7deab64b8cb4e31b600ad0d839b6d73\web"
    File /r ".\Bin\plugins\d7deab64b8cb4e31b600ad0d839b6d73\web\*.*"
    
    SetOutPath "$INSTDIR\plugins\dd537b5c6c074ae49cc8b0b2965ce54a"
    File ".\Bin\plugins\dd537b5c6c074ae49cc8b0b2965ce54a\*.dll"
    File ".\LmsaPlugins\toolBox\Ringtone\Comm\libmp3lame.32.dll"
    File ".\Bin\plugins\dd537b5c6c074ae49cc8b0b2965ce54a\lenovo.mbg.service.lmsa.toolbox.exe.config"
    File ".\Bin\plugins\dd537b5c6c074ae49cc8b0b2965ce54a\lenovo.mbg.service.lmsa.toolbox.exe"
    
    ${GetSize} "$INSTDIR" "/S=OK" $0 $1 $2
    IntFmt $0 "0x%08X" $0
    WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "EstimatedSize" "$0"
SectionEnd
    
Section -AdditionalIcons
    SetOutPath $INSTDIR
    #WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
    #CreateShortCut "$SMPROGRAMS\lmsa\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url"
    CreateShortCut "$SMPROGRAMS\lmsa\Uninstall.lnk" "$INSTDIR\uninst.exe"
SectionEnd

Section -Post
    WriteUninstaller "$INSTDIR\uninst.exe"
    WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_DIR_REGKEY}" "" "$INSTDIR\${PRODUCT_MAIN_EXE}"
    WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
    WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
    WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayIcon" "$INSTDIR\${PRODUCT_MAIN_EXE}"
    WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
    #WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
    WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
    WriteRegDWORD ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_WEBBROWSER_IE_VERSION}" "${PRODUCT_MAIN_EXE}" 0x11001
SectionEnd

Function LaunchLink
    ExecShell "" "$SMPROGRAMS\lmsa\${PRODUCT_LINK_NAME}"
FunctionEnd

Function un.onUninstSuccess
    # do something
    HideWindow
    MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) has been successfully removed from your computer."
FunctionEnd

Function un.onInit
    Call un.KillProcFunc
    !insertmacro MUI_UNGETLANGUAGE
FunctionEnd

Function un.PreUninstall
    ReadRegDWORD  $R0 ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_DIR_REGKEY}" "Upgrade"
    ; Not Upgrade
    ${IfNot} $R0 = 1
        MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely uninstall $(^Name) and all components?" IDYES +2
        Abort
        ExecWait "$INSTDIR\${PRODUCT_UNINSTALL_SURVEY}"
        ClearErrors
    ${EndIf}
FunctionEnd

Section Uninstall
    Call un.PreUninstall
    
    Delete "$INSTDIR\uninst.exe"
    
    ;Upgrade
    ${If} $R0 = 1
        CreateDirectory "${PRODUCT_TEMP}"
        CopyFiles /SILENT "$INSTDIR\*.xml" "${PRODUCT_TEMP}"
        CopyFiles /SILENT "$INSTDIR\*.json" "${PRODUCT_TEMP}"
        CopyFiles /SILENT "$INSTDIR\*.res" "${PRODUCT_TEMP}"
        CreateDirectory "${PRODUCT_TEMP}\logs"
        CopyFiles /SILENT "$INSTDIR\logs\*.*" "${PRODUCT_TEMP}\logs"
        CreateDirectory "${PRODUCT_TEMP}\plugins\8ab04aa975e34f1ca4f9dc3a81374e2c\log"
        CopyFiles /SILENT "$INSTDIR\plugins\8ab04aa975e34f1ca4f9dc3a81374e2c\log\*.*" "${PRODUCT_TEMP}\plugins\8ab04aa975e34f1ca4f9dc3a81374e2c\log"
        CreateDirectory "${PRODUCT_TEMP}\download"
        CopyFiles /SILENT "$INSTDIR\download\*.*" "${PRODUCT_TEMP}\download"
        Delete "$INSTDIR\*.*"
        RMDir /r "$INSTDIR"
        CreateDirectory "$INSTDIR"
        CopyFiles /SILENT "${PRODUCT_TEMP}\*.*" "$INSTDIR"
        Delete "${PRODUCT_TEMP}\*.*"
        RMDir /r "${PRODUCT_TEMP}"
    ${Else}
        Delete "$INSTDIR\*.*"
        RMDir /r "$INSTDIR"
    ${EndIf}
    #Delete "$INSTDIR\*.*"
    Delete "$SMPROGRAMS\lmsa\Uninstall.lnk"
    #Delete "$SMPROGRAMS\lmsa\Website.lnk"
    Delete "$DESKTOP\${PRODUCT_LINK_NAME}"
    Delete "$SMPROGRAMS\lmsa\${PRODUCT_LINK_NAME}"

    #RMDir /r "$INSTDIR"
    RMDir "$SMPROGRAMS\lmsa"

    DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}"
    DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_DIR_REGKEY}"
    #DeleteRegKey ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_WEBBROWSER_IE_VERSION}"
    SetAutoClose true
SectionEnd

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值