new convenient script methods
[chaz/yoink] / win32 / yoink.nsi
1 ;NSIS Modern User Interface
2 ;Start Menu Folder Selection Example Script
3 ;Written by Joost Verburg
4
5 ;--------------------------------
6 ;Include Modern UI
7
8 !include "MUI2.nsh"
9
10 ;--------------------------------
11 ;General
12
13 ;Name and file
14 Name "Yoink"
15 OutFile "${OUTFILE}"
16 SetCompressor /SOLID lzma
17
18 ;Default installation folder
19 InstallDir "$PROGRAMFILES\Yoink"
20
21 ;Get installation folder from registry if available
22 InstallDirRegKey HKCU "Software\Yoink" ""
23
24 ;Request application privileges for Windows Vista
25 RequestExecutionLevel user
26
27 ;--------------------------------
28 ;Interface Settings
29
30 !define MUI_ICON "${ROOTPATH}/win32/setup.ico"
31 !define MUI_UNICON "${ROOTPATH}/win32/uninstall.ico"
32
33 !define MUI_COMPONENTSPAGE_SMALLDESC
34
35 !define MUI_FINISHPAGE_RUN "$INSTDIR\yoink.exe"
36 !define MUI_FINISHPAGE_RUN_NOTCHECKED
37 !define MUI_FINISHPAGE_LINK "Visit the Yoink website"
38 !define MUI_FINISHPAGE_LINK_LOCATION "http://www.dogcows.com/"
39
40 !define MUI_ABORTWARNING
41
42 ;--------------------------------
43 ;Pages
44
45 !insertmacro MUI_PAGE_WELCOME
46 !insertmacro MUI_PAGE_COMPONENTS
47 !insertmacro MUI_PAGE_DIRECTORY
48 !insertmacro MUI_PAGE_INSTFILES
49 !insertmacro MUI_PAGE_FINISH
50
51 !insertmacro MUI_UNPAGE_CONFIRM
52 !insertmacro MUI_UNPAGE_INSTFILES
53
54 ;--------------------------------
55 ;Languages
56
57 !insertmacro MUI_LANGUAGE "English"
58
59 ;--------------------------------
60 ;Installer Sections
61
62 Section "Install Yoink!" SecInstallYoink
63
64 SetOutPath "$INSTDIR"
65
66 ;ADD YOUR OWN FILES HERE...
67 File /r "${INSTALLFILES}/*"
68
69 ;Store installation folder
70 WriteRegStr HKCU "Software\Yoink" "" $INSTDIR
71
72 ;Create uninstaller
73 WriteUninstaller "uninstall.exe"
74
75 ;Create shortcuts
76 CreateDirectory "$SMPROGRAMS\Yoink"
77 CreateShortCut "$SMPROGRAMS\Yoink\Play Yoink!.lnk" "$INSTDIR\yoink.exe"
78 CreateShortCut "$SMPROGRAMS\Yoink\Uninstall.lnk" "$INSTDIR\uninstall.exe"
79
80 WriteRegStr HKCU "Software\Games\Yoink" "" "$INSTDIR"
81 WriteRegStr HKCU "Software\Games\Yoink" "Version" "${VERSION}"
82 WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Yoink" "DisplayName" "Yoink"
83 WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Yoink" "DisplayVersion" "${VERSION}"
84 WriteRegStr HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Yoink" "UninstallString" "$INSTDIR\uninstall.exe"
85
86 SectionEnd
87
88 Section "Install desktop shortcut." SecInstallShortcut
89
90 ;Desktop shortcut
91 SetOverwrite on
92 CreateShortCut "$DESKTOP\Yoink.lnk" "$INSTDIR\yoink.exe"
93 SetOverwrite off
94
95 SectionEnd
96
97 ;--------------------------------
98 ;Descriptions
99
100 ;Language strings
101 LangString DESC_SecInstallYoink ${LANG_ENGLISH} "Install the game executable and data files."
102 LangString DESC_SecInstallShortcut ${LANG_ENGLISH} "Install a shortcut to the executable on the desktop."
103
104 ;Assign language strings to sections
105 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
106 !insertmacro MUI_DESCRIPTION_TEXT ${SecInstallYoink} $(DESC_SecInstallYoink)
107 !insertmacro MUI_DESCRIPTION_TEXT ${SecInstallShortcut} $(DESC_SecInstallShortcut)
108 !insertmacro MUI_FUNCTION_DESCRIPTION_END
109
110 ;--------------------------------
111 ;Uninstaller
112
113 Section "Uninstall"
114
115 Delete "$SMPROGRAMS\Yoink\*.*"
116 RMDir "$SMPROGRAMS\Yoink"
117 Delete "$DESKTOP\Yoink.lnk"
118
119 DeleteRegKey /ifempty HKCU "Software\Games\Yoink"
120 DeleteRegKey HKCU "Software\Microsoft\Windows\CurrentVersion\Uninstall\Yoink"
121
122 RMDir /r "$INSTDIR"
123
124 SectionEnd
125
126 ;--------------------------------
127 ;Functions
128
129 Function .onInit
130
131 ;Run the uninstaller if Yoink is already installed.
132 ReadRegStr $R0 HKCU \
133 "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\Yoink" \
134 "UninstallString"
135 StrCmp $R0 "" done
136
137 MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
138 "Yoink is already installed. $\n$\nClick `OK` to remove the \
139 previous version or `Cancel` to cancel the installation." \
140 IDOK uninst
141 Abort
142
143 ;Run the uninstaller
144 uninst:
145 ClearErrors
146 ExecWait $INSTDIR\uninstall.exe
147
148 done:
149
150 FunctionEnd
151
This page took 0.037148 seconds and 4 git commands to generate.