Advertisement
CubeWorld

Untitled

Jun 21st, 2013
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. !include "MUI2.nsh"
  2.  
  3. ;General
  4. Function .onInit
  5.  
  6.   ReadEnvStr $R0 SYSTEMDRIVE
  7.  
  8.   StrCpy $INSTDIR `$R0\MyExample\`
  9.  
  10. FunctionEnd
  11.   Name "MyExample"
  12.   OutFile "Setup.exe"
  13.   RequestExecutionLevel admin
  14.  
  15. ;--------------------------------
  16.   !define MUI_ABORTWARNING
  17.   !define MUI_FINISHPAGE_RUN
  18.   !define MUI_FINISHPAGE_RUN_FUNCTION "LaunchLink"
  19.   !define MUI_FINISHPAGE_SHOWREADME ""
  20.   !define MUI_FINISHPAGE_SHOWREADME_NOTCHECKED
  21.   !define MUI_FINISHPAGE_SHOWREADME_TEXT "Create Desktop Shortcut"
  22.   !define MUI_FINISHPAGE_SHOWREADME_FUNCTION finishpageaction
  23. ;--------------------------------
  24. ;Pages
  25.   !insertmacro MUI_PAGE_WELCOME
  26.   !insertmacro MUI_PAGE_LICENSE "${NSISDIR}\Docs\Modern UI\License.txt"
  27.   !insertmacro MUI_PAGE_DIRECTORY
  28.   !insertmacro MUI_PAGE_INSTFILES
  29.   !insertmacro MUI_PAGE_FINISH
  30.  
  31.   !insertmacro MUI_UNPAGE_WELCOME
  32.   !insertmacro MUI_UNPAGE_CONFIRM
  33.   !insertmacro MUI_UNPAGE_INSTFILES
  34.   !insertmacro MUI_UNPAGE_FINISH
  35. ;--------------------------------
  36. ;Languages
  37.   !insertmacro MUI_LANGUAGE "English"
  38. ;--------------------------------
  39. ;Installer Sections
  40. Section "Dummy Section" SecDummy
  41.   File "MyExample.exe"
  42.   File  "MyExample.ico"
  43.   File  "error.wav"
  44.   File  "success.wav"
  45.   File  "MyExample.dll"
  46.     CreateDirectory $INSTDIR\temp
  47.   SetOutPath "$INSTDIR"
  48.   WriteRegStr HKCU "Software\MyExample" "" $INSTDIR
  49.  
  50.   ;Create uninstaller
  51.   WriteUninstaller "$INSTDIR\Uninstall.exe"
  52.     WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\Product\MyExample" \
  53.                  "MyExample" "$\"$INSTDIR\uninstall.exe$\""
  54. SectionEnd
  55.  
  56. Section "Uninstall"
  57.  
  58. # Always delete uninstaller first
  59. delete $INSTDIR\uninstall.exe
  60.   delete $INSTDIR\MyExample.exe
  61.   delete $INSTDIR\MyExample.ico
  62.   delete $INSTDIR\error.wav
  63.   delete $INSTDIR\success.wav
  64.   delete $INSTDIR\MyExample.dll
  65.  
  66. SectionEnd
  67. ;--------------------------------
  68. ;Descriptions
  69.   LangString DESC_SecDummy ${LANG_ENGLISH} "Setup"
  70.   !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
  71.     !insertmacro MUI_DESCRIPTION_TEXT ${SecDummy} $(DESC_SecDummy)
  72.   !insertmacro MUI_FUNCTION_DESCRIPTION_END
  73.  
  74. ;--------------------------------
  75. ;Uninstaller Section
  76.  
  77. Section "Uninstall"
  78.   Delete "$INSTDIR\Uninstall.exe"
  79.   RMDir "$INSTDIR"
  80.   DeleteRegKey /ifempty HKCU "Software\MyExample"
  81. SectionEnd
  82.  
  83. Function LaunchLink
  84.   ExecShell "" "$INSTDIR\MyExample.exe"
  85. FunctionEnd
  86.  
  87. Function finishpageaction
  88. CreateShortcut "$desktop\MyExample.lnk" "$instdir\MyExample.exe"
  89.     WriteRegStr HKEY_CURRENT_USER "Software\Microsoft\Windows\CurrentVersion\Run" \
  90. "MyExample.exe" "$INSTDIR\MyExample.exe"
  91. FunctionEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement