UserVars.nsi 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. ; UserVars.nsi
  2. ;
  3. ; This script shows you how to declare and user variables.
  4. ;--------------------------------
  5. Name "User Variables Text"
  6. OutFile "UserVars.exe"
  7. InstallDir "$PROGRAMFILES\User Variables Test"
  8. RequestExecutionLevel admin
  9. ;--------------------------------
  10. ;Pages
  11. Page directory
  12. Page instfiles
  13. UninstPage uninstConfirm
  14. UninstPage instfiles
  15. ;--------------------------------
  16. ; Declaration of user variables (Var command), allowed charaters for variables names : [a-z][A-Z][0-9] and '_'
  17. Var "Name"
  18. Var "Serial"
  19. Var "Info"
  20. ;--------------------------------
  21. ; Installer
  22. Section "Dummy Section" SecDummy
  23. StrCpy $0 "Admin"
  24. StrCpy "$Name" $0
  25. StrCpy "$Serial" "12345"
  26. MessageBox MB_OK "User Name: $Name $\n$\nSerial Number: $Serial"
  27. CreateDirectory $INSTDIR
  28. WriteUninstaller "$INSTDIR\Uninst.exe"
  29. SectionEnd
  30. Section "Another Section"
  31. Var /GLOBAL "AnotherVar"
  32. StrCpy $AnotherVar "test"
  33. SectionEnd
  34. ;--------------------------------
  35. ; Uninstaller
  36. Section "Uninstall"
  37. StrCpy $Info "User variables test uninstalled successfully."
  38. Delete "$INSTDIR\Uninst.exe"
  39. RmDir $INSTDIR
  40. SectionEnd
  41. Function un.OnUninstSuccess
  42. HideWindow
  43. MessageBox MB_OK "$Info"
  44. FunctionEnd