⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vpndialer-setup-light.nsi

📁 VPN拨号程序源码(from sourceforge.net)
💻 NSI
字号:
; VPNDialer-Setup.nsi
;
; This script builds the installer for the VPNDialer
;
;

; define version
!define VERSION "0.3.7"

;***************************************************************************************
; Macro - Upgrade DLL File
; Written by Joost Verburg
; ------------------------
;
; Example of usage:
; !insertmacro UpgradeDLL "dllname.dll" "$SYSDIR\dllname.dll"
;
; !define UPGRADEDLL_NOREGISTER if you want to upgrade a DLL which cannot
; be registered
;
; Note that this macro sets overwrite to TRY. Change it back to whatever 
; you want after you insert the macro.

!macro UpgradeDLL LOCALFILE DESTFILE

  Push $R0
  Push $R1
  Push $R2
  Push $R3

  ;------------------------
  ;Check file and version

  IfFileExists "${DESTFILE}" "" "copy_${LOCALFILE}"

  ClearErrors
    GetDLLVersionLocal "${LOCALFILE}" $R0 $R1
    GetDLLVersion "${DESTFILE}" $R2 $R3
  IfErrors "upgrade_${LOCALFILE}"

  IntCmpU $R0 $R2 "" "done_${LOCALFILE}" "upgrade_${LOCALFILE}"
  IntCmpU $R1 $R3 "done_${LOCALFILE}" "done_${LOCALFILE}" "upgrade_${LOCALFILE}"

  ;------------------------
  ;Let's upgrade the DLL!

  SetOverwrite try

  "upgrade_${LOCALFILE}:"
;    !ifndef UPGRADEDLL_NOREGISTER
;      ;Unregister the DLL
;      UnRegDLL "${DESTFILE}"
;    !endif

  ;------------------------
  ;Try to copy the DLL directly

  ClearErrors
    StrCpy $R0 "${DESTFILE}"
    Call ":file_${LOCALFILE}"
  IfErrors "" "noreboot_${LOCALFILE}"

  ;------------------------
  ;DLL is in use. Copy it to a temp file and Rename it on reboot.

  GetTempFileName $R0
    Call ":file_${LOCALFILE}"
  Rename /REBOOTOK $R0 "${DESTFILE}"

  ;------------------------
  ;Register the DLL on reboot

;  !ifndef UPGRADEDLL_NOREGISTER
;    WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\RunOnce" "Register ${DESTFILE}" '"$SYSDIR\rundll32.exe" "${DESTFILE},DllRegisterServer"'
;  !endif

  Goto "done_${LOCALFILE}"

  ;------------------------
  ;DLL does not exist - just extract

  "copy_${LOCALFILE}:"
    StrCpy $R0 "${DESTFILE}"
    Call ":file_${LOCALFILE}"

  ;------------------------
  ;Register the DLL

  "noreboot_${LOCALFILE}:"
;    !ifndef UPGRADEDLL_NOREGISTER
;      RegDLL "${DESTFILE}"
;    !endif

  ;------------------------
  ;Done

  "done_${LOCALFILE}:"

  Pop $R3
  Pop $R2
  Pop $R1
  Pop $R0

  ;------------------------
  ;End

  Goto "end_${LOCALFILE}"

  ;------------------------
  ;Called to extract the DLL

  "file_${LOCALFILE}:"
    File /oname=$R0 "${LOCALFILE}"
    Return

  "end_${LOCALFILE}:"

!macroend


;***************************************************************************************
; Global Settings
;***************************************************************************************
; The name of the installer
Name "VPNDialer"

; The file to write
OutFile "VPNDialer-Setup-Light-${VERSION}.exe"

; The default installation directory
InstallDir "$PROGRAMFILES\VPNDialer"
; Registry key to check for directory (so if you install again, it will 
; overwrite the old one automatically)
InstallDirRegKey HKLM SOFTWARE\Evidian\VPNDialer "Install_Dir"

; The text to prompt the user to enter a directory
ComponentText "This will install the VPNDialer on your computer. Select which optional things you want installed."
; The text to prompt the user to enter a directory
DirText "Choose a directory to install into:"

; Show Details when installing and deinstalling
ShowInstDetails show
ShowUninstDetails show

Function .onInit
	; set $SMPROGRAMS to all-users
	SetShellVarContext all
FunctionEnd

Function un.onInit
	; read install-dir from registry
	ReadRegStr $INSTDIR HKLM SOFTWARE\Evidian\VPNDialer "Install_Dir"
	; set $SMPROGRAMS to all-users
	SetShellVarContext all
FunctionEnd

Function .onInstSuccess
  ; Write the installation path into the registry
  WriteRegStr HKLM SOFTWARE\Evidian\VPNDialer "Install_Dir" "$INSTDIR"
  ; Write the installed Version to registry
  WriteRegStr HKLM SOFTWARE\Evidian\VPNDialer "InstalledVersion" ${VERSION}
FunctionEnd

Section "VPNDialer (recommended)"
  ; Set output path to the installation directory.
  SetOutPath $INSTDIR
  ; Put file there
  File "..\Release\VPNDialer.exe"
  File "..\VPNDialer-History.txt"
  File "..\License.txt"
  CreateDirectory "$SMPROGRAMS\VPNDialer"
  CreateShortCut "$SMPROGRAMS\VPNDialer\VPNDialer.lnk" "$INSTDIR\VPNDialer.exe" "" "$INSTDIR\VPNDialer.exe" 0
  CreateShortCut "$SMPROGRAMS\VPNDialer\History.lnk" "$INSTDIR\VPNDialer-History.txt" "" "$INSTDIR\VPNDialer-History.txt" 0
  CreateShortCut "$SMPROGRAMS\VPNDialer\License.lnk" "$INSTDIR\License.txt" "" "$INSTDIR\License.txt" 0
SectionEnd

; optional section
Section "Uninstaller"
  SectionIn 1
  SectionIn 2
  SetOutPath $INSTDIR
  ; Write the uninstall keys for Windows
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VPNDialer" "DisplayName" "VPNDialer (remove only)"
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VPNDialer" "UninstallString" '"$INSTDIR\uninstall\uninstVPNDialer-Setup.exe"'
  WriteUninstaller "$INSTDIR\uninstVPNDialer-Setup.exe"
  CreateDirectory "$SMPROGRAMS\VPNDialer"
  CreateShortCut "$SMPROGRAMS\VPNDialer\Uninstall.lnk" "$INSTDIR\uninstVPNDialer-Setup.exe" "" "$INSTDIR\uninstVPNDialer-Setup.exe" 0
SectionEnd

; uninstall stuff

UninstallText "This will uninstall VPNDialer."

; special uninstall section.
Section "Uninstall"
  SetShellVarContext all
  ; remove registry keys
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\VPNDialer"
  DeleteRegValue HKLM SOFTWARE\Evidian\VPNDialer InstalledVersion
  ; remove files
  ;VPNDialer
  Delete /REBOOTOK "$INSTDIR\VPNDialer.exe"
  Delete "$INSTDIR\VPNDialer-History.txt"
  Delete "$INSTDIR\License.txt"
  ; MUST REMOVE UNINSTALLER, too
  Delete "$INSTDIR\uninstVPNDialer-Setup.exe"
  ; remove shortcuts, if any.
  Delete "$SMPROGRAMS\VPNDialer\*.*"
  ; remove directories used.
  RMDir "$SMPROGRAMS\VPNDialer"
  RMDir "$INSTDIR"
SectionEnd

; eof

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -