nsis64 / Examples / UserVars.nsi

; UserVars.nsi
; This script shows you how to declare and user variables.


  Name "User Variables Text"
  OutFile "UserVars.exe"
  InstallDir "$PROGRAMFILES\User Variables Test"
  RequestExecutionLevel admin

  Page directory
  Page instfiles
  UninstPage uninstConfirm
  UninstPage instfiles

; Declaration of user variables (Var command), allowed charaters for variables names : [a-z][A-Z][0-9] and '_'

  Var "Name"
  Var "Serial"
  Var "Info"

; Installer

Section "Dummy Section" SecDummy

     StrCpy $0 "Admin"
     StrCpy "$Name" $0
     StrCpy "$Serial" "12345"
     MessageBox MB_OK "User Name: $Name $\n$\nSerial Number: $Serial"

     CreateDirectory $INSTDIR
     WriteUninstaller "$INSTDIR\Uninst.exe"

Section "Another Section"

     Var /GLOBAL "AnotherVar"

     StrCpy $AnotherVar "test"


; Uninstaller

Section "Uninstall"

     StrCpy $Info "User variables test uninstalled successfully."
     Delete "$INSTDIR\Uninst.exe"
     RmDir $INSTDIR


Function un.OnUninstSuccess

     MessageBox MB_OK "$Info"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.