. Nsi installation script example

Source: Internet
Author: User

; The Egret Video Converter setup script.
; Pay attention to the order of various definitions,
; 1. Global Configuration
2. Page Configuration
3. insert various languages! Insertmacro MUI_LANGUAGE
4. define various langstrings
5. Package and retain files

! Include "MUI2.nsh"

######################################## ####################################
######################################## ####################################
#################### Place some predefined constants ############## ##################

! Define PACKET_PATH "client"; program packaging directory
! Define PRODUCT_APP "VideoConverter.exe"; executable file body
! Define PRODUCT_UNINST "UnInstall.exe"; uninstall file name
 
! Define PRODUCT_VERSION "2.2"; visible version number of the software
! Define PRODUCT_WEB "http://www.egretsoft.com"; Web site
! Define PRODUCT_VENDOR "egret"; OEM
 
! Define PRODUCT_FILEVERSION "2.2009.815.1"; internal property Number of the software (4)
! Define WRITE_REG_POS "HKEY_LOCAL_MACHINE"; follow for writing data to the Registry (administrator privilege)
 
! Define PRODUCT_MAIN_MUTEX "EGRET_CONVERTER_2009"; Master software lock
! Define PRODUCT_SETUP_MUTEX "EGRET_SETUP_MUTEX"; the installer lock and only one installer can be run.

;-----------------------------------------------------------------------------
; Some additional resources
! Define RES_PATH "setupres"; Resource Directory
! Define SPLASHBMP "splash.bmp"; pop-up screen File
 
#################### Place some predefined constants ############## ##################
######################################## ####################################
######################################## ####################################

 

 

 

 

 

######################################## ####################################
######################################## ####################################
########################## Global configuration items ########## ######################
;------------------------------------------------------
; Use the maximum global Compression
;------------------------------------------------------
SetCompressor/SOLID lzma

;------------------------------------------------------
; Software name
;------------------------------------------------------
! Ifdef NAME
Name NAME
! Else
Name "$ (ProductName)-$ {PRODUCT_VERSION }"
! Endif

;------------------------------------------------------
Name of the compiled output file
;------------------------------------------------------
! Ifdef OUTFILE
OutFile "$ {OUTFILE }"
! Else
OutFile "egretconverter-00000000product_version0000-00000000product_vendor0000.exe"
! Endif

;------------------------------------------------------
; Title name
;------------------------------------------------------
! Ifdef CAPTION
Caption "$ {CAPTION }"
! Else
Caption "$ (ProductName)-$ {PRODUCT_VERSION} $ (StrSetupWizard )"
! Endif

;------------------------------------------------------
; Horizontal text
;------------------------------------------------------
! Ifdef BRANDINGTEXT
BrandingText "$ {BRANDINGTEXT }";
! Else
BrandingText "";
! Endif

;------------------------------------------------------
; Default installation directory = program + product name
;------------------------------------------------------
InstallDir "$ PROGRAMFILES \ $ (ProductName )"

;------------------------------------------------------
; Default registry placement target
;------------------------------------------------------
;! Define PRODUCT_DIR_REGKEY "Software \ Microsoft \ Windows \ CurrentVersion \ App Paths \ $ (ProductName )"
! Define PRODUCT_UNINST_KEY "Software \ Microsoft \ Windows \ CurrentVersion \ Uninstall \ $ (ProductName )"
InstallDirRegKey HKLM "$ {PRODUCT_UNINST_KEY}" "UninstallString"
; RequestExecutionLevel user

 

;--------------------------------
Interface style settings

! Define MUI_HEADERIMAGE; defined as the HEADER Mode
! Define MUI_ABORTWARNING; click "cancel" to display the dialog box.

! Define MUI_FINISHPAGE_LINK "$ {PRODUCT_WEB }"
! Define MUI_FINISHPAGE_LINK_LOCATION "$ {PRODUCT_WEB }"
! Define MUI_FINISHPAGE_RUN "$ INSTDIR \ $ {PRODUCT_APP }"

! Define MUI_ICON "$ {RES_PATH} \ Install-Icon.ico"; installation icon
! Define MUI_UNICON "$ {RES_PATH} \ UnInstall-Icon.ico"; unmounted icon
! Define MUI_HEADERIMAGE_BITMAP "$ {RES_PATH} \ Install-Header.bmp"; installed HEADER Image
! Define MUI_HEADERIMAGE_UNBITMAP "$ {RES_PATH} \ Install-Header.bmp"; unmounted HEADER Image

########################## Global configuration items ########## ######################
######################################## ####################################
######################################## ####################################

 

 

######################################## ####################################
######################################## ####################################
########################## Installation page ############ ####################

! Insertmacro MUI_PAGE_LICENSE $ (myLicenseData); "$ {MY_LICENCE_FILE }"
! Insertmacro MUI_PAGE_DIRECTORY
! Insertmacro MUI_PAGE_INSTFILES


! Insertmacro MUI_UNPAGE_CONFIRM
! Insertmacro MUI_UNPAGE_INSTFILES
! Insertmacro MUI_PAGE_FINISH

########################## Installation page ############ ####################
######################################## ####################################
######################################## ####################################

 

 
######################################## ####################################
######################################## ####################################
########################## Language processing items ########### #####################

; Load language files
! Insertmacro MUI_LANGUAGE "English"
! Insertmacro MUI_LANGUAGE "French"
! Insertmacro MUI_LANGUAGE "SimpChinese"
! Insertmacro MUI_LANGUAGE "TradChinese"
! Insertmacro MUI_LANGUAGE "Japanese"

# LoadLanguageFile "$ {NSISDIR} \ Contrib \ Language files \ English. nlf"
# LoadLanguageFile "$ {NSISDIR} \ Contrib \ Language files \ French. nlf"
# LoadLanguageFile "$ {NSISDIR} \ Contrib \ Language files \ TradChinese. nlf"
# Loademediagefile "$ {NSISDIR} \ Contrib \ Language files \ SimpChinese. nlf"
# LoadLanguageFile "$ {NSISDIR} \ Contrib \ Language files \ Japan. nlf"

; License file
LicenseLangString myLicenseData $ {LANG_ENGLISH} "$ {RES_PATH} \ license.txt"
LicenseLangString myLicenseData $ {LANG_FRENCH} "$ {RES_PATH} \ license.txt"
LicenseLangString myLicenseData $ {LANG_TRADCHINESE} "$ {RES_PATH} \ license-tc.txt"
LicenseLangString myLicenseData $ {LANG_SIMPCHINESE} "$ {RES_PATH} \ license-sc.txt"
LicenseLangString myLicenseData $ {LANG_JAPANESE} "$ {RES_PATH} \ license.txt"
LicenseData $ (myLicenseData)

; Product Name
LangString ProductName $ {LANG_ENGLISH} "Egret Video Converter"
LangString ProductName $ {LANG_FRENCH} "Egret Video Converter"
LangString ProductName $ {LANG_TRADCHINESE} ""
LangString ProductName $ {LANG_SIMPCHINESE} "egret Video Converter"
LangString ProductName $ {LANG_JAPANESE} "Egret Video Converter"

; Official Site
LangString WebShortName $ {LANG_ENGLISH} "Official Site"
LangString WebShortName $ {LANG_FRENCH} "Site Officiel"
LangString WebShortName $ {LANG_TRADCHINESE} "Official Website"
LangString WebShortName $ {LANG_SIMPCHINESE} "Official Site"
LangString WebShortName $ {LANG_JAPANESE} "formula サイト"

; Uninstall the program
LangString UninstallName $ {LANG_ENGLISH} "Uninstall"
LangString UninstallName $ {LANG_FRENCH} "Uninstall"
LangString UninstallName $ {LANG_TRADCHINESE} "Uninstall"
LangString UninstallName $ {LANG_SIMPCHINESE} "Uninstall"
LangString UninstallName $ {LANG_JAPANESE} "Uninstall"

; Egret Studio
LangString StrCompanyName $ {LANG_ENGLISH} "Bailu Studio"
LangString StrCompanyName $ {LANG_FRENCH} "Bailu Studio"
LangString StrCompanyName $ {LANG_TRADCHINESE} "Bailu Studio"
LangString StrCompanyName $ {LANG_SIMPCHINESE} "egret Studio-Bailu Studio"
LangString StrCompanyName $ {LANG_JAPANESE} "Bailu Studio"

; Installation Wizard
LangString StrSetupWizard $ {LANG_ENGLISH} "Setup Wizard"
LangString StrSetupWizard $ {LANG_FRENCH} "Assistant"
LangString StrSetupWizard $ {LANG_TRADCHINESE} "Security Risk Mitigation"
LangString StrSetupWizard $ {LANG_SIMPCHINESE} "Installation Wizard"
LangString StrSetupWizard $ {LANG_JAPANESE} "too many attempts have been made before these attempts"

The installer is running.
LangString StrAlreadyHaveOne $ {LANG_ENGLISH} "Already exist one instance ."
LangString StrAlreadyHaveOne $ {LANG_FRENCH} "Il existe d é j à un exemple ."
LangString StrAlreadyHaveOne $ {LANG_TRADCHINESE} "An security program is running. "
LangString StrAlreadyHaveOne $ {LANG_SIMPCHINESE} "an installer is running. "
LangString StrAlreadyHaveOne $ {LANG_JAPANESE} "when there are too many threads in the response row, there are too many threads in the response ."

Thank you for your use.
LangString StrUninstallThanks $ {LANG_ENGLISH} "Thank you very much! $ (ProductName) has been successfully removed ."
LangString StrUninstallThanks $ {LANG_FRENCH} "Merci pour votre utilisation! $ (ProductName) a é té suppri é de votre ordinateur ."
LangString StrUninstallThanks $ {LANG_TRADCHINESE} "Thank you very much for your use! $ (ProductName) has been successfully removed from your computer. "
LangString StrUninstallThanks $ {LANG_SIMPCHINESE} "Thank you very much for your use! $ (ProductName) has been successfully removed from your computer. "
LangString StrUninstallThanks $ {LANG_JAPANESE} "this is really awesome! $ (ProductName) Deleted successfully ."

The main program is running.
LangString StrMainRunning $ {LANG_ENGLISH} "System detected you are running $ (ProductName). Setup will not be able to continue ."
LangString StrMainRunning $ {LANG_FRENCH} "Le syst è me a d é tect é que vous utilisez $ (ProductName). Le programme d 'installation ne sera pas en mesure de continuer ."
LangString StrMainRunning $ {LANG_TRADCHINESE} "indicates that you are running $ (ProductName ). The security program will not be able to continue. "
LangString StrMainRunning $ {LANG_SIMPCHINESE} "the system detects that you are running $ (ProductName ). The installer cannot continue. "
LangString StrMainRunning $ {LANG_JAPANESE} "$ (ProductName) when there is a large number of zookeeper attempts when there is a large number of zookeeper. When there are too many rows, then there are too many rows before there are too many rows ."

########################## Language processing items ########### #####################
######################################## ####################################
######################################## ####################################

;--------------------------------
; Various types of guaranteed-pack and retained files
 
! Insertmacro MUI_RESERVEFILE_LANGDLL
ReserveFile "$ {NSISDIR} \ Plugins \ advsplash. dll"
ReserveFile "$ {RES_PATH }\$ {SPLASHBMP }"


######################################## ####################################
######################################## ####################################
########################### Main installation function ########## ##########################
Section "MainSection" SEC01

; Set the output directory
SetOutPath "$ INSTDIR"

; Decompress all files
File/r "$ {PACKET_PATH }\*.*"

Create the anti-installation program and the anti-installation registry key
WriteUninstaller "$ INSTDIR \$ {PRODUCT_UNINST }"
WriteRegStr $ {WRITE_REG_POS} "$ {PRODUCT_UNINST_KEY}" "DisplayName" $ (ProductName )"
WriteRegStr $ {WRITE_REG_POS} "$ {PRODUCT_UNINST_KEY}" "UninstallString" "$ INSTDIR \ $ {PRODUCT_UNINST }"
WriteRegStr $ {WRITE_REG_POS} "$ {PRODUCT_UNINST_KEY}" "DisplayIcon" $ INSTDIR \ $ {PRODUCT_APP }"
WriteRegStr $ {WRITE_REG_POS} "$ {PRODUCT_UNINST_KEY}" "DisplayVersion" $ {PRODUCT_VERSION }"
WriteRegStr $ {WRITE_REG_POS} "$ {PRODUCT_UNINST_KEY}" "HelpLink" "$ {PRODUCT_WEB }"
WriteRegStr $ {WRITE_REG_POS} "$ {PRODUCT_UNINST_KEY}" "Publisher" $ (StrCompanyName )"
WriteRegStr $ {WRITE_REG_POS} "$ {PRODUCT_UNINST_KEY}" "URLUpdateInfo" "$ {PRODUCT_WEB }"
WriteRegStr $ {WRITE_REG_POS} "$ {PRODUCT_UNINST_KEY}" "INSTDIR" "$ INSTDIR"

; Create the Start menu (because it is hidden, the program group name is fixed)
CreateDirectory "$ SMPROGRAMS \ $ (ProductName )"
CreateShortCut "$ SMPROGRAMS \ $ (ProductName) \ $ (UninstallName). lnk" "$ INSTDIR \ $ {PRODUCT_UNINST }"
CreateShortCut "$ SMPROGRAMS \ $ (ProductName). lnk" "$ INSTDIR \ $ {PRODUCT_APP }"
CreateShortCut "$ SMPROGRAMS \ $ (ProductName) \ $ (WebShortName). lnk" "$ {PRODUCT_WEB }"

; Create a desktop icon
CreateShortCut "$ DESKTOP \ $ (ProductName). lnk" "$ INSTDIR \ $ {PRODUCT_APP }"

; Create a shortcut icon
CreateShortCut "$ QUICKLAUNCH \ $ (ProductName). lnk" "$ INSTDIR \ $ {PRODUCT_APP }"

SectionEnd
########################### Main installation function ########## ##########################
######################################## ####################################
######################################## ####################################

 

 

 

 

######################################## ####################################
######################################## ####################################
########################### Entry function ########### #########################
Function. onInit

; Detect multiple instances
System: Call 'kernel32: CreateMutexA (I 0, I 0, t "$ {PRODUCT_SETUP_MUTEX}") I. r1? E'
Pop $ R0
StrCmp $ R0 0 + 3
MessageBox MB_ OK | MB_ICONEXCLAMATION "$ (StrAlreadyHaveOne )"
Abort

; Pop-up Screen
InitPluginsDir
File "/oname = $ PLUGINSDIR \ Splash_splash.bmp" "$ {RES_PATH }\$ {SPLASHBMP }"
Advsplash: show 1000 600 400 0xFF00FF "$ PLUGINSDIR \ Splash_splash"; Use the pop-up plug-in to display the pop-up Screen
Pop $0; $0. If '1' is returned, the user closes the screen. If '0' is returned, the screen ends normally. If '-1' is returned, the screen displays an error.

 

! Insertmacro MUI_LANGDLL_DISPLAY; first, the language page is displayed. Because there is a jump in it, it must be placed in the function.

FunctionEnd
########################### Entry function ########### #########################
######################################## ####################################
######################################## ####################################

 

 

 

 

######################################## ####################################
######################################## ####################################
########### #########################

Section "Uninstall"

# Delete the installation directory
RMDir/r "$ INSTDIR"

# Delete start/program items
RMDir/r "$ SMPROGRAMS \ $ (ProductName )"

# Delete the Add/delete List Option
DeleteRegKey $ {WRITE_REG_POS} "$ {PRODUCT_UNINST_KEY }"
; DeleteRegKey HKLM "$ {PRODUCT_DIR_REGKEY }"

; Delete the desktop icon (delete the names of all languages to prevent problems. Try not to let the user manually delete it)
Delete "$ DESKTOP \ $ (ProductName). lnk"
Delete "$ DESKTOP \ Egret Video Converter. lnk"

; Delete the shortcut icon
Delete "$ QUICKLAUNCH \ $ (ProductName). lnk"
Delete "$ QUICKLAUNCH \ Egret Video Converter. lnk"

The interface is automatically closed.
SetAutoClose true

SectionEnd

Function un. onInit

Check whether the main program is running and cannot continue
System: Call 'kernel32: CreateMutexA (I 0, I 0, t "$ {PRODUCT_MAIN_MUTEX}") I. r1? E'
Pop $ R0
StrCmp $ R0 0 + 3
MessageBox MB_ OK | MB_ICONEXCLAMATION "$ (StrMainRunning )"
Abort

; There seems to be a BUG, that is, the mutex must be closed. Otherwise, there is no way to uninstall it. The real HANDLE is stored in $1.
This BUG not only affects uninstallation but also causes errors when the program is started!
System: Call 'kernel32: CloseHandle (I "$1 ")'

; Prompt the user to wait for an error
; MessageBox MB_ICONQUESTION | MB_YESNO | MB_DEFBUTTON2 "$ (STR_UNINSTALL_CONFIRM)" IDYES + 2
; Abort

; Language switching
;! Insertmacro MUI_UNGETLANGUAGE

FunctionEnd

Function un. onUninstSuccess
; Prompt
MessageBox MB_ICONINFORMATION | MB_ OK "$ (StrUninstallThanks )"
FunctionEnd

########### #########################
######################################## ####################################
######################################## ####################################

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.