Statistiques
| Révision :

root / tmp / org.txm.setups / nsis-2.5 / Examples / bigtest.nsi @ 3097

Historique | Voir | Annoter | Télécharger (7,78 ko)

1 2961 mdecorde
; bigtest.nsi
2 2961 mdecorde
;
3 2961 mdecorde
; This script attempts to test most of the functionality of the NSIS exehead.
4 2961 mdecorde
5 2961 mdecorde
;--------------------------------
6 2961 mdecorde
7 2961 mdecorde
!ifdef HAVE_UPX
8 2961 mdecorde
!packhdr tmp.dat "upx\upx -9 tmp.dat"
9 2961 mdecorde
!endif
10 2961 mdecorde
11 2961 mdecorde
!ifdef NOCOMPRESS
12 2961 mdecorde
SetCompress off
13 2961 mdecorde
!endif
14 2961 mdecorde
15 2961 mdecorde
;--------------------------------
16 2961 mdecorde
17 2961 mdecorde
Name "BigNSISTest"
18 2961 mdecorde
Caption "NSIS Big Test"
19 2961 mdecorde
Icon "${NSISDIR}\Contrib\Graphics\Icons\nsis1-install.ico"
20 2961 mdecorde
OutFile "bigtest.exe"
21 2961 mdecorde
22 2961 mdecorde
SetDateSave on
23 2961 mdecorde
SetDatablockOptimize on
24 2961 mdecorde
CRCCheck on
25 2961 mdecorde
SilentInstall normal
26 2961 mdecorde
BGGradient 000000 800000 FFFFFF
27 2961 mdecorde
InstallColors FF8080 000030
28 2961 mdecorde
XPStyle on
29 2961 mdecorde
30 2961 mdecorde
InstallDir "$PROGRAMFILES\NSISTest\BigNSISTest"
31 2961 mdecorde
InstallDirRegKey HKLM "Software\NSISTest\BigNSISTest" "Install_Dir"
32 2961 mdecorde
33 2961 mdecorde
CheckBitmap "${NSISDIR}\Contrib\Graphics\Checks\classic-cross.bmp"
34 2961 mdecorde
35 2961 mdecorde
LicenseText "A test text, make sure it's all there"
36 2961 mdecorde
LicenseData "bigtest.nsi"
37 2961 mdecorde
38 2961 mdecorde
RequestExecutionLevel admin
39 2961 mdecorde
40 2961 mdecorde
;--------------------------------
41 2961 mdecorde
42 2961 mdecorde
Page license
43 2961 mdecorde
Page components
44 2961 mdecorde
Page directory
45 2961 mdecorde
Page instfiles
46 2961 mdecorde
47 2961 mdecorde
UninstPage uninstConfirm
48 2961 mdecorde
UninstPage instfiles
49 2961 mdecorde
50 2961 mdecorde
;--------------------------------
51 2961 mdecorde
52 2961 mdecorde
!ifndef NOINSTTYPES ; only if not defined
53 2961 mdecorde
  InstType "Most"
54 2961 mdecorde
  InstType "Full"
55 2961 mdecorde
  InstType "More"
56 2961 mdecorde
  InstType "Base"
57 2961 mdecorde
  ;InstType /NOCUSTOM
58 2961 mdecorde
  ;InstType /COMPONENTSONLYONCUSTOM
59 2961 mdecorde
!endif
60 2961 mdecorde
61 2961 mdecorde
AutoCloseWindow false
62 2961 mdecorde
ShowInstDetails show
63 2961 mdecorde
64 2961 mdecorde
;--------------------------------
65 2961 mdecorde
66 2961 mdecorde
Section "" ; empty string makes it hidden, so would starting with -
67 2961 mdecorde
68 2961 mdecorde
  ; write reg info
69 2961 mdecorde
  StrCpy $1 "POOOOOOOOOOOP"
70 2961 mdecorde
  DetailPrint "I like to be able to see what is going on (debug) $1"
71 2961 mdecorde
  WriteRegStr HKLM SOFTWARE\NSISTest\BigNSISTest "Install_Dir" "$INSTDIR"
72 2961 mdecorde
73 2961 mdecorde
  ; write uninstall strings
74 2961 mdecorde
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BigNSISTest" "DisplayName" "BigNSISTest (remove only)"
75 2961 mdecorde
  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BigNSISTest" "UninstallString" '"$INSTDIR\bt-uninst.exe"'
76 2961 mdecorde
77 2961 mdecorde
  SetOutPath $INSTDIR
78 2961 mdecorde
  File /a "silent.nsi"
79 2961 mdecorde
  CreateDirectory "$INSTDIR\MyProjectFamily\MyProject" ; 2 recursively create a directory for fun.
80 2961 mdecorde
  WriteUninstaller "bt-uninst.exe"
81 2961 mdecorde
82 2961 mdecorde
  Nop ; for fun
83 2961 mdecorde
84 2961 mdecorde
SectionEnd
85 2961 mdecorde
86 2961 mdecorde
Section "TempTest"
87 2961 mdecorde
88 2961 mdecorde
SectionIn 1 2 3
89 2961 mdecorde
  Start: MessageBox MB_OK "Start:"
90 2961 mdecorde
91 2961 mdecorde
  MessageBox MB_YESNO "Goto MyLabel" IDYES MyLabel
92 2961 mdecorde
93 2961 mdecorde
  MessageBox MB_OK "Right before MyLabel:"
94 2961 mdecorde
95 2961 mdecorde
  MyLabel: MessageBox MB_OK "MyLabel:"
96 2961 mdecorde
97 2961 mdecorde
  MessageBox MB_OK "Right after MyLabel:"
98 2961 mdecorde
99 2961 mdecorde
  MessageBox MB_YESNO "Goto Start:?" IDYES Start
100 2961 mdecorde
101 2961 mdecorde
SectionEnd
102 2961 mdecorde
103 2961 mdecorde
SectionGroup /e SectionGroup1
104 2961 mdecorde
105 2961 mdecorde
Section "Test Registry/INI functions"
106 2961 mdecorde
107 2961 mdecorde
SectionIn 1 4 3
108 2961 mdecorde
109 2961 mdecorde
  WriteRegStr HKLM SOFTWARE\NSISTest\BigNSISTest "StrTest_INSTDIR" "$INSTDIR"
110 2961 mdecorde
  WriteRegDword HKLM SOFTWARE\NSISTest\BigNSISTest "DwordTest_0xDEADBEEF" 0xdeadbeef
111 2961 mdecorde
  WriteRegDword HKLM SOFTWARE\NSISTest\BigNSISTest "DwordTest_123456" 123456
112 2961 mdecorde
  WriteRegDword HKLM SOFTWARE\NSISTest\BigNSISTest "DwordTest_0123" 0123
113 2961 mdecorde
  WriteRegBin HKLM SOFTWARE\NSISTest\BigNSISTest "BinTest_deadbeef01f00dbeef" "DEADBEEF01F00DBEEF"
114 2961 mdecorde
  StrCpy $8 "$SYSDIR\IniTest"
115 2961 mdecorde
  WriteINIStr "$INSTDIR\test.ini"  "MySection" "Value1" $8
116 2961 mdecorde
  WriteINIStr "$INSTDIR\test.ini"  "MySectionIni" "Value1" $8
117 2961 mdecorde
  WriteINIStr "$INSTDIR\test.ini"  "MySectionIni" "Value2" $8
118 2961 mdecorde
  WriteINIStr "$INSTDIR\test.ini"  "IniOn" "Value1" $8
119 2961 mdecorde
120 2961 mdecorde
  Call MyFunctionTest
121 2961 mdecorde
122 2961 mdecorde
  DeleteINIStr "$INSTDIR\test.ini" "IniOn" "Value1"
123 2961 mdecorde
  DeleteINISec "$INSTDIR\test.ini" "MySectionIni"
124 2961 mdecorde
125 2961 mdecorde
  ReadINIStr $1 "$INSTDIR\test.ini" "MySectionIni" "Value1"
126 2961 mdecorde
  StrCmp $1 "" INIDelSuccess
127 2961 mdecorde
    MessageBox MB_OK "DeleteINISec failed"
128 2961 mdecorde
  INIDelSuccess:
129 2961 mdecorde
130 2961 mdecorde
  ClearErrors
131 2961 mdecorde
  ReadRegStr $1 HKCR "software\microsoft" xyz_cc_does_not_exist
132 2961 mdecorde
  IfErrors 0 NoError
133 2961 mdecorde
    MessageBox MB_OK "could not read from HKCR\software\microsoft\xyz_cc_does_not_exist"
134 2961 mdecorde
    Goto ErrorYay
135 2961 mdecorde
  NoError:
136 2961 mdecorde
    MessageBox MB_OK "read '$1' from HKCR\software\microsoft\xyz_cc_does_not_exist"
137 2961 mdecorde
  ErrorYay:
138 2961 mdecorde
139 2961 mdecorde
SectionEnd
140 2961 mdecorde
141 2961 mdecorde
Section "Test CreateShortCut"
142 2961 mdecorde
143 2961 mdecorde
  SectionIn 1 2 3
144 2961 mdecorde
145 2961 mdecorde
  Call CSCTest
146 2961 mdecorde
147 2961 mdecorde
SectionEnd
148 2961 mdecorde
149 2961 mdecorde
SectionGroup Group2
150 2961 mdecorde
151 2961 mdecorde
Section "Test Branching"
152 2961 mdecorde
153 2961 mdecorde
  BeginTestSection:
154 2961 mdecorde
  SectionIn 1 2 3
155 2961 mdecorde
156 2961 mdecorde
  SetOutPath $INSTDIR
157 2961 mdecorde
158 2961 mdecorde
  IfFileExists "$INSTDIR\LogicLib.nsi" 0 BranchTest69
159 2961 mdecorde
160 2961 mdecorde
    MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to overwrite $INSTDIR\LogicLib.nsi?" IDNO NoOverwrite ; skipped if file doesn't exist
161 2961 mdecorde
162 2961 mdecorde
    BranchTest69:
163 2961 mdecorde
164 2961 mdecorde
    SetOverwrite ifnewer ; NOT AN INSTRUCTION, NOT COUNTED IN SKIPPINGS
165 2961 mdecorde
166 2961 mdecorde
  NoOverwrite:
167 2961 mdecorde
168 2961 mdecorde
  File "LogicLib.nsi" ; skipped if answered no
169 2961 mdecorde
  SetOverwrite try ; NOT AN INSTRUCTION, NOT COUNTED IN SKIPPINGS
170 2961 mdecorde
171 2961 mdecorde
  MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to skip the rest of this section?" IDYES EndTestBranch
172 2961 mdecorde
  MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to go back to the beginning of this section?" IDYES BeginTestSection
173 2961 mdecorde
  MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to hide the installer and wait five seconds?" IDNO NoHide
174 2961 mdecorde
175 2961 mdecorde
    HideWindow
176 2961 mdecorde
    Sleep 5000
177 2961 mdecorde
    BringToFront
178 2961 mdecorde
179 2961 mdecorde
  NoHide:
180 2961 mdecorde
181 2961 mdecorde
  MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to call the function 5 times?" IDNO NoRecurse
182 2961 mdecorde
183 2961 mdecorde
    StrCpy $1 "x"
184 2961 mdecorde
185 2961 mdecorde
  LoopTest:
186 2961 mdecorde
187 2961 mdecorde
    Call myfunc
188 2961 mdecorde
    StrCpy $1 "x$1"
189 2961 mdecorde
    StrCmp $1 "xxxxxx" 0 LoopTest
190 2961 mdecorde
191 2961 mdecorde
  NoRecurse:
192 2961 mdecorde
193 2961 mdecorde
  EndTestBranch:
194 2961 mdecorde
195 2961 mdecorde
SectionEnd
196 2961 mdecorde
197 2961 mdecorde
SectionGroupEnd
198 2961 mdecorde
199 2961 mdecorde
Section "Test CopyFiles"
200 2961 mdecorde
201 2961 mdecorde
  SectionIn 1 2 3
202 2961 mdecorde
203 2961 mdecorde
  SetOutPath $INSTDIR\cpdest
204 2961 mdecorde
  CopyFiles "$WINDIR\*.ini" "$INSTDIR\cpdest" 0
205 2961 mdecorde
206 2961 mdecorde
SectionEnd
207 2961 mdecorde
208 2961 mdecorde
SectionGroupEnd
209 2961 mdecorde
210 2961 mdecorde
Section "Test Exec functions" TESTIDX
211 2961 mdecorde
212 2961 mdecorde
  SectionIn 1 2 3
213 2961 mdecorde
214 2961 mdecorde
  SearchPath $1 notepad.exe
215 2961 mdecorde
216 2961 mdecorde
  MessageBox MB_OK "notepad.exe=$1"
217 2961 mdecorde
  Exec '"$1"'
218 2961 mdecorde
  ExecShell "open" '"$INSTDIR"'
219 2961 mdecorde
  Sleep 500
220 2961 mdecorde
  BringToFront
221 2961 mdecorde
222 2961 mdecorde
SectionEnd
223 2961 mdecorde
224 2961 mdecorde
Section "Test ActiveX control registration"
225 2961 mdecorde
226 2961 mdecorde
  SectionIn 2
227 2961 mdecorde
228 2961 mdecorde
  UnRegDLL "$SYSDIR\spin32.ocx"
229 2961 mdecorde
  Sleep 1000
230 2961 mdecorde
  RegDLL "$SYSDIR\spin32.ocx"
231 2961 mdecorde
  Sleep 1000
232 2961 mdecorde
233 2961 mdecorde
SectionEnd
234 2961 mdecorde
235 2961 mdecorde
;--------------------------------
236 2961 mdecorde
237 2961 mdecorde
Function "CSCTest"
238 2961 mdecorde
239 2961 mdecorde
  CreateDirectory "$SMPROGRAMS\Big NSIS Test"
240 2961 mdecorde
  SetOutPath $INSTDIR ; for working directory
241 2961 mdecorde
  CreateShortCut "$SMPROGRAMS\Big NSIS Test\Uninstall BIG NSIS Test.lnk" "$INSTDIR\bt-uninst.exe" ; use defaults for parameters, icon, etc.
242 2961 mdecorde
  ; this one will use notepad's icon, start it minimized, and give it a hotkey (of Ctrl+Shift+Q)
243 2961 mdecorde
  CreateShortCut "$SMPROGRAMS\Big NSIS Test\silent.nsi.lnk" "$INSTDIR\silent.nsi" "" "$WINDIR\notepad.exe" 0 SW_SHOWMINIMIZED CONTROL|SHIFT|Q
244 2961 mdecorde
  CreateShortCut "$SMPROGRAMS\Big NSIS Test\TheDir.lnk" "$INSTDIR\" "" "" 0 SW_SHOWMAXIMIZED CONTROL|SHIFT|Z
245 2961 mdecorde
246 2961 mdecorde
FunctionEnd
247 2961 mdecorde
248 2961 mdecorde
Function myfunc
249 2961 mdecorde
250 2961 mdecorde
  StrCpy $2 "MyTestVar=$1"
251 2961 mdecorde
  MessageBox MB_OK "myfunc: $2"
252 2961 mdecorde
253 2961 mdecorde
FunctionEnd
254 2961 mdecorde
255 2961 mdecorde
Function MyFunctionTest
256 2961 mdecorde
257 2961 mdecorde
  ReadINIStr $1 "$INSTDIR\test.ini" "MySectionIni" "Value1"
258 2961 mdecorde
  StrCmp $1 $8 NoFailedMsg
259 2961 mdecorde
    MessageBox MB_OK "WriteINIStr failed"
260 2961 mdecorde
261 2961 mdecorde
  NoFailedMsg:
262 2961 mdecorde
263 2961 mdecorde
FunctionEnd
264 2961 mdecorde
265 2961 mdecorde
Function .onSelChange
266 2961 mdecorde
267 2961 mdecorde
  SectionGetText ${TESTIDX} $0
268 2961 mdecorde
  StrCmp $0 "" e
269 2961 mdecorde
    SectionSetText ${TESTIDX} ""
270 2961 mdecorde
  Goto e2
271 2961 mdecorde
e:
272 2961 mdecorde
  SectionSetText ${TESTIDX} "TextInSection"
273 2961 mdecorde
e2:
274 2961 mdecorde
275 2961 mdecorde
FunctionEnd
276 2961 mdecorde
277 2961 mdecorde
;--------------------------------
278 2961 mdecorde
279 2961 mdecorde
; Uninstaller
280 2961 mdecorde
281 2961 mdecorde
UninstallText "This will uninstall example2. Hit next to continue."
282 2961 mdecorde
UninstallIcon "${NSISDIR}\Contrib\Graphics\Icons\nsis1-uninstall.ico"
283 2961 mdecorde
284 2961 mdecorde
Section "Uninstall"
285 2961 mdecorde
286 2961 mdecorde
  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\BigNSISTest"
287 2961 mdecorde
  DeleteRegKey HKLM "SOFTWARE\NSISTest\BigNSISTest"
288 2961 mdecorde
  Delete "$INSTDIR\silent.nsi"
289 2961 mdecorde
  Delete "$INSTDIR\LogicLib.nsi"
290 2961 mdecorde
  Delete "$INSTDIR\bt-uninst.exe"
291 2961 mdecorde
  Delete "$INSTDIR\test.ini"
292 2961 mdecorde
  Delete "$SMPROGRAMS\Big NSIS Test\*.*"
293 2961 mdecorde
  RMDir "$SMPROGRAMS\BiG NSIS Test"
294 2961 mdecorde
295 2961 mdecorde
  MessageBox MB_YESNO|MB_ICONQUESTION "Would you like to remove the directory $INSTDIR\cpdest?" IDNO NoDelete
296 2961 mdecorde
    Delete "$INSTDIR\cpdest\*.*"
297 2961 mdecorde
    RMDir "$INSTDIR\cpdest" ; skipped if no
298 2961 mdecorde
  NoDelete:
299 2961 mdecorde
300 2961 mdecorde
  RMDir "$INSTDIR\MyProjectFamily\MyProject"
301 2961 mdecorde
  RMDir "$INSTDIR\MyProjectFamily"
302 2961 mdecorde
  RMDir "$INSTDIR"
303 2961 mdecorde
304 2961 mdecorde
  IfFileExists "$INSTDIR" 0 NoErrorMsg
305 2961 mdecorde
    MessageBox MB_OK "Note: $INSTDIR could not be removed!" IDOK 0 ; skipped if file doesn't exist
306 2961 mdecorde
  NoErrorMsg:
307 2961 mdecorde
308 2961 mdecorde
SectionEnd