]>
Commit | Line | Data |
---|---|---|
4d59bff9 | 1 | ; |
cfbba5b9 | 2 | ; smartmontools install NSIS script |
4d59bff9 | 3 | ; |
cfbba5b9 | 4 | ; Home page of code is: http://smartmontools.sourceforge.net |
4d59bff9 | 5 | ; |
cfbba5b9 | 6 | ; Copyright (C) 2006-11 Christian Franke <smartmontools-support@lists.sourceforge.net> |
4d59bff9 | 7 | ; |
cfbba5b9 GI |
8 | ; This program is free software; you can redistribute it and/or modify |
9 | ; it under the terms of the GNU General Public License as published by | |
10 | ; the Free Software Foundation; either version 2, or (at your option) | |
11 | ; any later version. | |
4d59bff9 | 12 | ; |
cfbba5b9 GI |
13 | ; You should have received a copy of the GNU General Public License |
14 | ; (for example COPYING); If not, see <http://www.gnu.org/licenses/>. | |
15 | ; | |
a7e8ffec | 16 | ; $Id: installer.nsi 3298 2011-03-22 18:36:44Z chrfranke $ |
4d59bff9 GG |
17 | ; |
18 | ||
19 | ||
20 | ;-------------------------------------------------------------------- | |
21 | ; Command line arguments: | |
cfbba5b9 | 22 | ; makensis -DINPDIR=<input-dir> -DOUTFILE=<output-file> -DVERSTR=<version-string> installer.nsi |
4d59bff9 GG |
23 | |
24 | !ifndef INPDIR | |
25 | !define INPDIR "." | |
26 | !endif | |
27 | ||
28 | !ifndef OUTFILE | |
29 | !define OUTFILE "smartmontools.win32-setup.exe" | |
30 | !endif | |
31 | ||
32 | ;-------------------------------------------------------------------- | |
33 | ; General | |
34 | ||
35 | Name "smartmontools" | |
36 | OutFile "${OUTFILE}" | |
37 | ||
38 | SetCompressor /solid lzma | |
39 | ||
40 | XPStyle on | |
41 | InstallColors /windows | |
42 | ||
43 | InstallDir "$PROGRAMFILES\smartmontools" | |
44 | InstallDirRegKey HKLM "Software\smartmontools" "Install_Dir" | |
a37e7145 | 45 | Var UBCDDIR |
4d59bff9 GG |
46 | |
47 | LicenseData "${INPDIR}\doc\COPYING.txt" | |
48 | ||
a7e8ffec GI |
49 | !include "FileFunc.nsh" |
50 | !include "Sections.nsh" | |
51 | ||
52 | !insertmacro GetParameters | |
53 | !insertmacro GetOptions | |
54 | ||
55 | RequestExecutionLevel admin | |
56 | ||
4d59bff9 GG |
57 | ;-------------------------------------------------------------------- |
58 | ; Pages | |
59 | ||
60 | Page license | |
61 | Page components | |
a37e7145 GG |
62 | Page directory SkipProgPath "" "" |
63 | PageEx directory | |
64 | PageCallbacks SkipUBCDPath "" "" | |
65 | DirText "Setup will install the UBCD4Win plugin in the following folder." | |
66 | DirVar $UBCDDIR | |
67 | PageExEnd | |
4d59bff9 GG |
68 | Page instfiles |
69 | ||
70 | UninstPage uninstConfirm | |
71 | UninstPage instfiles | |
72 | ||
73 | InstType "Full" | |
74 | InstType "Extract files only" | |
a37e7145 GG |
75 | InstType "Drive menu" |
76 | InstType "UBCD4Win plugin" | |
4d59bff9 GG |
77 | |
78 | ||
79 | ;-------------------------------------------------------------------- | |
80 | ; Sections | |
81 | ||
a37e7145 | 82 | SectionGroup "!Program files" |
4d59bff9 | 83 | |
a37e7145 | 84 | Section "smartctl" SMARTCTL_SECTION |
4d59bff9 GG |
85 | |
86 | SectionIn 1 2 | |
87 | ||
88 | SetOutPath "$INSTDIR\bin" | |
89 | File "${INPDIR}\bin\smartctl.exe" | |
90 | ||
91 | SectionEnd | |
92 | ||
a37e7145 | 93 | Section "smartd" SMARTD_SECTION |
4d59bff9 GG |
94 | |
95 | SectionIn 1 2 | |
96 | ||
97 | SetOutPath "$INSTDIR\bin" | |
a37e7145 GG |
98 | |
99 | ; Stop service ? | |
100 | StrCpy $1 "" | |
101 | IfFileExists "$INSTDIR\bin\smartd.exe" 0 nosrv | |
102 | ReadRegStr $0 HKLM "System\CurrentControlSet\Services\smartd" "ImagePath" | |
103 | StrCmp $0 "" nosrv | |
104 | ExecWait "net stop smartd" $1 | |
105 | nosrv: | |
4d59bff9 GG |
106 | File "${INPDIR}\bin\smartd.exe" |
107 | ||
108 | IfFileExists "$INSTDIR\bin\smartd.conf" 0 +2 | |
109 | MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Replace existing configuration file$\n$INSTDIR\bin\smartd.conf ?" IDYES 0 IDNO +2 | |
110 | File "${INPDIR}\doc\smartd.conf" | |
111 | ||
112 | IfFileExists "$WINDIR\system32\cmd.exe" 0 +2 | |
113 | File /nonfatal "${INPDIR}\bin\syslogevt.exe" | |
114 | ||
a37e7145 GG |
115 | ; Restart service ? |
116 | StrCmp $1 "0" 0 +3 | |
117 | MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Restart smartd service ?" IDYES 0 IDNO +2 | |
118 | ExecWait "net start smartd" | |
119 | ||
4d59bff9 GG |
120 | SectionEnd |
121 | ||
2127e193 GI |
122 | Section "smartctl-nc (GSmartControl)" SMARTCTL_NC_SECTION |
123 | ||
124 | SectionIn 1 2 | |
125 | ||
126 | SetOutPath "$INSTDIR\bin" | |
127 | File "${INPDIR}\bin\smartctl-nc.exe" | |
128 | ||
129 | SectionEnd | |
130 | ||
cfbba5b9 GI |
131 | Section "drivedb.h (Drive Database)" DRIVEDB_SECTION |
132 | ||
133 | SectionIn 1 2 | |
134 | ||
135 | SetOutPath "$INSTDIR\bin" | |
136 | File "${INPDIR}\bin\drivedb.h" | |
137 | File "${INPDIR}\bin\update-smart-drivedb.exe" | |
138 | ||
139 | SectionEnd | |
140 | ||
4d59bff9 GG |
141 | SectionGroupEnd |
142 | ||
a37e7145 | 143 | Section "!Documentation" DOC_SECTION |
4d59bff9 GG |
144 | |
145 | SectionIn 1 2 | |
146 | ||
147 | SetOutPath "$INSTDIR\doc" | |
148 | File "${INPDIR}\doc\AUTHORS.txt" | |
149 | File "${INPDIR}\doc\CHANGELOG.txt" | |
150 | File "${INPDIR}\doc\COPYING.txt" | |
151 | File "${INPDIR}\doc\INSTALL.txt" | |
152 | File "${INPDIR}\doc\NEWS.txt" | |
153 | File "${INPDIR}\doc\README.txt" | |
154 | File "${INPDIR}\doc\TODO.txt" | |
155 | File "${INPDIR}\doc\WARNINGS.txt" | |
cfbba5b9 | 156 | File "${INPDIR}\doc\checksums.txt" |
4d59bff9 GG |
157 | File "${INPDIR}\doc\smartctl.8.html" |
158 | File "${INPDIR}\doc\smartctl.8.txt" | |
159 | File "${INPDIR}\doc\smartd.8.html" | |
160 | File "${INPDIR}\doc\smartd.8.txt" | |
161 | File "${INPDIR}\doc\smartd.conf" | |
162 | File "${INPDIR}\doc\smartd.conf.5.html" | |
163 | File "${INPDIR}\doc\smartd.conf.5.txt" | |
164 | ||
165 | SectionEnd | |
166 | ||
a37e7145 | 167 | Section "Uninstaller" UNINST_SECTION |
4d59bff9 GG |
168 | |
169 | SectionIn 1 | |
170 | AddSize 35 | |
171 | ||
172 | CreateDirectory "$INSTDIR" | |
173 | ||
174 | ; Save installation location | |
175 | WriteRegStr HKLM "Software\smartmontools" "Install_Dir" "$INSTDIR" | |
176 | ||
177 | ; Write uninstall keys and program | |
178 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "DisplayName" "smartmontools" | |
2127e193 GI |
179 | !ifdef VERSTR |
180 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "DisplayVersion" "${VERSTR}" | |
181 | !endif | |
a37e7145 | 182 | ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "Publisher" "smartmontools" |
4d59bff9 | 183 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "UninstallString" '"$INSTDIR\uninst-smartmontools.exe"' |
a37e7145 GG |
184 | ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLInfoAbout" "http://smartmontools.sourceforge.net/" |
185 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "HelpLink" "http://smartmontools.sourceforge.net/" | |
186 | ;WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLUpdateInfo" "http://sourceforge.net/project/showfiles.php?group_id=64297" | |
187 | WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "URLUpdateInfo" "http://smartmontools-win32.dyndns.org/" | |
4d59bff9 GG |
188 | WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "NoModify" 1 |
189 | WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" "NoRepair" 1 | |
190 | WriteUninstaller "uninst-smartmontools.exe" | |
191 | ||
192 | SectionEnd | |
193 | ||
a37e7145 | 194 | Section "Start Menu Shortcuts" MENU_SECTION |
4d59bff9 GG |
195 | |
196 | SectionIn 1 | |
197 | ||
a7e8ffec GI |
198 | SetShellVarContext all |
199 | ||
4d59bff9 GG |
200 | CreateDirectory "$SMPROGRAMS\smartmontools" |
201 | ||
202 | ; smartctl | |
203 | IfFileExists "$INSTDIR\bin\smartctl.exe" 0 noctl | |
204 | SetOutPath "$INSTDIR\bin" | |
205 | DetailPrint "Create file: $INSTDIR\bin\smartctl-run.bat" | |
a37e7145 GG |
206 | Push "$INSTDIR\bin\smartctl-run.bat" |
207 | Call CreateSmartctlBat | |
208 | IfFileExists "$WINDIR\system32\cmd.exe" 0 +2 | |
209 | CreateShortCut "$SMPROGRAMS\smartmontools\smartctl (CMD).lnk" "cmd.exe" "/k smartctl-run.bat" | |
4d59bff9 GG |
210 | CreateDirectory "$SMPROGRAMS\smartmontools\smartctl Examples" |
211 | FileOpen $0 "$SMPROGRAMS\smartmontools\smartctl Examples\!Read this first!.txt" "w" | |
a37e7145 | 212 | FileWrite $0 "All the example commands in this directory$\r$\napply to the first drive (sda).$\r$\n" |
4d59bff9 | 213 | FileClose $0 |
a37e7145 GG |
214 | CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\All info (-a).lnk" "$INSTDIR\bin\smartctl-run.bat" "-a sda" |
215 | CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Identify drive (-i).lnk" "$INSTDIR\bin\smartctl-run.bat" "-i sda" | |
216 | CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART attributes (-A).lnk" "$INSTDIR\bin\smartctl-run.bat" "-A sda" | |
217 | CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART capabilities (-c).lnk" "$INSTDIR\bin\smartctl-run.bat" "-c sda" | |
218 | CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART health status (-H).lnk" "$INSTDIR\bin\smartctl-run.bat" "-H sda" | |
219 | CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART error log (-l error).lnk" "$INSTDIR\bin\smartctl-run.bat" "-l error sda" | |
220 | CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\SMART selftest log (-l selftest).lnk" "$INSTDIR\bin\smartctl-run.bat" "-l selftest sda" | |
221 | CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start long selftest (-t long).lnk" "$INSTDIR\bin\smartctl-run.bat" "-t long sda" | |
222 | CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start offline test (-t offline).lnk" "$INSTDIR\bin\smartctl-run.bat" "-t offline sda" | |
223 | CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Start short selftest (-t short).lnk" "$INSTDIR\bin\smartctl-run.bat" "-t short sda" | |
224 | CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Stop(Abort) selftest (-X).lnk" "$INSTDIR\bin\smartctl-run.bat" "-X sda" | |
225 | CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Turn SMART off (-s off).lnk" "$INSTDIR\bin\smartctl-run.bat" "-s off sda" | |
226 | CreateShortCut "$SMPROGRAMS\smartmontools\smartctl Examples\Turn SMART on (-s on).lnk" "$INSTDIR\bin\smartctl-run.bat" "-s on sda" | |
4d59bff9 GG |
227 | noctl: |
228 | ||
229 | ; smartd | |
230 | IfFileExists "$INSTDIR\bin\smartd.exe" 0 nod | |
231 | SetOutPath "$INSTDIR\bin" | |
232 | DetailPrint "Create file: $INSTDIR\bin\smartd-run.bat" | |
233 | FileOpen $0 "$INSTDIR\bin\smartd-run.bat" "w" | |
cfbba5b9 | 234 | FileWrite $0 '@echo off$\r$\necho smartd %1 %2 %3 %4 %5$\r$\n"$INSTDIR\bin\smartd" %1 %2 %3 %4 %5$\r$\npause$\r$\n' |
4d59bff9 GG |
235 | FileClose $0 |
236 | CreateDirectory "$SMPROGRAMS\smartmontools\smartd Examples" | |
a37e7145 | 237 | CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon start, smartd.log.lnk" "$INSTDIR\bin\smartd-run.bat" "-l local0" |
4d59bff9 | 238 | IfFileExists "$WINDIR\system32\cmd.exe" 0 +2 |
a37e7145 | 239 | CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon start, eventlog.lnk" "$INSTDIR\bin\smartd-run.bat" "" |
4d59bff9 GG |
240 | CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Daemon stop.lnk" "$INSTDIR\bin\smartd-run.bat" "stop" |
241 | CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Do all tests once (-q onecheck).lnk" "$INSTDIR\bin\smartd-run.bat" "-q onecheck" | |
242 | CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Debug mode (-d).lnk" "$INSTDIR\bin\smartd-run.bat" "-d" | |
243 | IfFileExists "$WINDIR\notepad.exe" 0 nopad | |
244 | CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Edit smartd.conf.lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\smartd.conf" | |
245 | CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\View smartd.log.lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\smartd.log" | |
246 | nopad: | |
247 | ||
248 | ; smartd service (not on 9x/ME) | |
249 | IfFileExists "$WINDIR\system32\cmd.exe" 0 nosvc | |
a37e7145 GG |
250 | CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, eventlog, 30min.lnk" "$INSTDIR\bin\smartd-run.bat" "install" |
251 | CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, smartd.log, 10min.lnk" "$INSTDIR\bin\smartd-run.bat" "install -l local0 -i 600" | |
252 | CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service install, smartd.log, 30min.lnk" "$INSTDIR\bin\smartd-run.bat" "install -l local0" | |
4d59bff9 GG |
253 | CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service remove.lnk" "$INSTDIR\bin\smartd-run.bat" "remove" |
254 | DetailPrint "Create file: $INSTDIR\bin\net-run.bat" | |
255 | FileOpen $0 "$INSTDIR\bin\net-run.bat" "w" | |
256 | FileWrite $0 "@echo off$\r$\necho net %1 %2 %3 %4 %5$\r$\nnet %1 %2 %3 %4 %5$\r$\npause$\r$\n" | |
257 | FileClose $0 | |
258 | CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service start.lnk" "$INSTDIR\bin\net-run.bat" "start smartd" | |
259 | CreateShortCut "$SMPROGRAMS\smartmontools\smartd Examples\Service stop.lnk" "$INSTDIR\bin\net-run.bat" "stop smartd" | |
260 | nosvc: | |
261 | nod: | |
262 | ||
263 | ; Documentation | |
264 | IfFileExists "$INSTDIR\doc\README.TXT" 0 nodoc | |
265 | SetOutPath "$INSTDIR\doc" | |
266 | CreateDirectory "$SMPROGRAMS\smartmontools\Documentation" | |
267 | CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartctl manual page (html).lnk" "$INSTDIR\doc\smartctl.8.html" | |
268 | CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd manual page (html).lnk" "$INSTDIR\doc\smartd.8.html" | |
269 | CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf manual page (html).lnk" "$INSTDIR\doc\smartd.conf.5.html" | |
270 | CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartctl manual page (txt).lnk" "$INSTDIR\doc\smartctl.8.txt" | |
271 | CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd manual page (txt).lnk" "$INSTDIR\doc\smartd.8.txt" | |
272 | CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf manual page (txt).lnk" "$INSTDIR\doc\smartd.conf.5.txt" | |
cfbba5b9 | 273 | IfFileExists "$WINDIR\notepad.exe" 0 +5 |
4d59bff9 | 274 | CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\smartd.conf sample.lnk" "$WINDIR\notepad.exe" "$INSTDIR\doc\smartd.conf" |
cfbba5b9 GI |
275 | IfFileExists "$INSTDIR\bin\drivedb.h" 0 +3 |
276 | CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\drivedb.h (view).lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\drivedb.h" | |
277 | CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\drivedb-add.h (create, edit).lnk" "$WINDIR\notepad.exe" "$INSTDIR\bin\drivedb-add.h" | |
4d59bff9 GG |
278 | CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\AUTHORS.lnk" "$INSTDIR\doc\AUTHORS.txt" |
279 | CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\CHANGELOG.lnk" "$INSTDIR\doc\CHANGELOG.txt" | |
280 | CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\COPYING.lnk" "$INSTDIR\doc\COPYING.txt" | |
281 | CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\INSTALL.lnk" "$INSTDIR\doc\INSTALL.txt" | |
282 | CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\NEWS.lnk" "$INSTDIR\doc\NEWS.txt" | |
283 | CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\README.lnk" "$INSTDIR\doc\README.txt" | |
284 | CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\TODO.lnk" "$INSTDIR\doc\TODO.txt" | |
285 | CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\WARNINGS.lnk" "$INSTDIR\doc\WARNINGS.txt" | |
a37e7145 | 286 | CreateShortCut "$SMPROGRAMS\smartmontools\Documentation\Windows version download page.lnk" "http://smartmontools-win32.dyndns.org/smartmontools/" |
4d59bff9 GG |
287 | nodoc: |
288 | ||
289 | ; Homepage | |
290 | CreateShortCut "$SMPROGRAMS\smartmontools\smartmontools Home Page.lnk" "http://smartmontools.sourceforge.net/" | |
291 | ||
cfbba5b9 GI |
292 | ; drivedb.h update |
293 | IfFileExists "$INSTDIR\bin\update-smart-drivedb.exe" 0 +2 | |
294 | CreateShortCut "$SMPROGRAMS\smartmontools\drivedb.h update.lnk" "$INSTDIR\bin\update-smart-drivedb.exe" | |
295 | ||
4d59bff9 GG |
296 | ; Uninstall |
297 | IfFileExists "$INSTDIR\uninst-smartmontools.exe" 0 +2 | |
298 | CreateShortCut "$SMPROGRAMS\smartmontools\Uninstall smartmontools.lnk" "$INSTDIR\uninst-smartmontools.exe" | |
299 | ||
300 | SectionEnd | |
301 | ||
a37e7145 | 302 | Section "Add install dir to PATH" PATH_SECTION |
4d59bff9 GG |
303 | |
304 | SectionIn 1 | |
305 | ||
306 | IfFileExists "$WINDIR\system32\cmd.exe" 0 +3 | |
307 | Push "$INSTDIR\bin" | |
308 | Call AddToPath | |
309 | ||
310 | SectionEnd | |
311 | ||
a37e7145 GG |
312 | SectionGroup "Add smartctl to drive menu" |
313 | ||
314 | !macro DriveMenuRemove | |
315 | DetailPrint "Remove drive menu entries" | |
316 | DeleteRegKey HKCR "Drive\shell\smartctl0" | |
317 | DeleteRegKey HKCR "Drive\shell\smartctl1" | |
318 | DeleteRegKey HKCR "Drive\shell\smartctl2" | |
319 | DeleteRegKey HKCR "Drive\shell\smartctl3" | |
320 | DeleteRegKey HKCR "Drive\shell\smartctl4" | |
321 | DeleteRegKey HKCR "Drive\shell\smartctl5" | |
322 | !macroend | |
323 | ||
a7e8ffec | 324 | Section "Remove existing entries first" DRIVE_REMOVE_SECTION |
a37e7145 GG |
325 | SectionIn 3 |
326 | !insertmacro DriveMenuRemove | |
327 | SectionEnd | |
328 | ||
329 | !macro DriveSection id name args | |
330 | Section 'smartctl ${args} ...' DRIVE_${id}_SECTION | |
331 | SectionIn 3 | |
cfbba5b9 | 332 | Call CheckSmartctlBat |
a37e7145 GG |
333 | DetailPrint 'Add drive menu entry "${name}": smartctl ${args} ...' |
334 | WriteRegStr HKCR "Drive\shell\smartctl${id}" "" "${name}" | |
335 | WriteRegStr HKCR "Drive\shell\smartctl${id}\command" "" '"$INSTDIR\bin\smartctl-run.bat" ${args} %L' | |
336 | SectionEnd | |
337 | !macroend | |
338 | ||
339 | !insertmacro DriveSection 0 "SMART all info" "-a" | |
340 | !insertmacro DriveSection 1 "SMART status" "-Hc" | |
341 | !insertmacro DriveSection 2 "SMART attributes" "-A" | |
342 | !insertmacro DriveSection 3 "SMART short selftest" "-t short" | |
343 | !insertmacro DriveSection 4 "SMART long selftest" "-t long" | |
344 | !insertmacro DriveSection 5 "SMART continue selective selftest" '-t "selective,cont"' | |
345 | ||
346 | SectionGroupEnd | |
347 | ||
348 | Section "UBCD4Win Plugin" UBCD_SECTION | |
349 | ||
350 | SectionIn 4 | |
351 | ||
352 | SetOutPath "$UBCDDIR" | |
353 | DetailPrint "Create file: smartmontools.inf" | |
354 | FileOpen $0 "$UBCDDIR\smartmontools.inf" "w" | |
355 | FileWrite $0 '; smartmontools.inf$\r$\n; PE Builder v3 plug-in INF file$\r$\n' | |
356 | FileWrite $0 '; Created by smartmontools installer$\r$\n' | |
357 | FileWrite $0 '; http://smartmontools.sourceforge.net/$\r$\n$\r$\n' | |
358 | FileWrite $0 '[Version]$\r$\nSignature= "$$Windows NT$$"$\r$\n$\r$\n' | |
359 | FileWrite $0 '[PEBuilder]$\r$\nName="Disk -Diagnostic: smartmontools"$\r$\n' | |
360 | FileWrite $0 'Enable=1$\r$\nHelp="files\smartctl.8.html"$\r$\n$\r$\n' | |
361 | FileWrite $0 '[WinntDirectories]$\r$\na=Programs\smartmontools,2$\r$\n$\r$\n' | |
362 | FileWrite $0 '[SourceDisksFolders]$\r$\nfiles=a,,1$\r$\n$\r$\n' | |
363 | FileWrite $0 '[Append]$\r$\nnu2menu.xml, smartmontools_nu2menu.xml$\r$\n' | |
364 | FileClose $0 | |
365 | ||
366 | DetailPrint "Create file: smartmontools_nu2menu.xml" | |
367 | FileOpen $0 "$UBCDDIR\smartmontools_nu2menu.xml" "w" | |
368 | FileWrite $0 '<!-- Nu2Menu entry for smartmontools -->$\r$\n<NU2MENU>$\r$\n' | |
369 | FileWrite $0 '$\t<MENU ID="Programs">$\r$\n$\t$\t<MITEM TYPE="POPUP" MENUID="Disk Tools">' | |
370 | FileWrite $0 'Disk Tools</MITEM>$\r$\n$\t</MENU>$\r$\n$\t<MENU ID="Disk Tools">$\r$\n' | |
371 | FileWrite $0 '$\t$\t<MITEM TYPE="POPUP" MENUID="Diagnostic">Diagnostic</MITEM>$\r$\n$\t</MENU>' | |
372 | FileWrite $0 '$\r$\n$\t<MENU ID="Diagnostic">$\r$\n$\t$\t<MITEM TYPE="ITEM" DISABLED="' | |
373 | FileWrite $0 '@Not(@FileExists(@GetProgramDrive()\Programs\smartmontools\smartctl.exe))" ' | |
374 | FileWrite $0 'CMD="RUN" FUNC="cmd.exe /k cd /d @GetProgramDrive()\Programs\smartmontools&' | |
375 | FileWrite $0 'set PATH=@GetProgramDrive()\Programs\smartmontools;%PATH%&smartctl-run.bat ">' | |
376 | FileWrite $0 'smartctl</MITEM>$\r$\n$\t</MENU>$\r$\n</NU2MENU>$\r$\n' | |
377 | FileClose $0 | |
378 | ||
379 | SetOutPath "$UBCDDIR\files" | |
380 | DetailPrint "Create file: smartctl-run.bat" | |
381 | Push "$UBCDDIR\files\smartctl-run.bat" | |
382 | Call CreateSmartctlBat | |
383 | File "${INPDIR}\bin\smartctl.exe" | |
384 | File "${INPDIR}\bin\smartd.exe" | |
385 | File "${INPDIR}\doc\smartctl.8.html" | |
386 | File "${INPDIR}\doc\smartctl.8.txt" | |
387 | File "${INPDIR}\doc\smartd.8.html" | |
388 | File "${INPDIR}\doc\smartd.8.txt" | |
389 | File "${INPDIR}\doc\smartd.conf" | |
390 | ||
391 | SectionEnd | |
392 | ||
393 | ||
4d59bff9 GG |
394 | ;-------------------------------------------------------------------- |
395 | ||
396 | Section "Uninstall" | |
397 | ||
a37e7145 GG |
398 | ; Stop & remove service |
399 | IfFileExists "$INSTDIR\bin\smartd.exe" 0 nosrv | |
400 | ReadRegStr $0 HKLM "System\CurrentControlSet\Services\smartd" "ImagePath" | |
401 | StrCmp $0 "" nosrv | |
402 | ExecWait "net stop smartd" | |
403 | MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Remove smartd service ?" IDYES 0 IDNO nosrv | |
404 | ExecWait "$INSTDIR\bin\smartd.exe remove" | |
405 | nosrv: | |
406 | ||
407 | ; Remove installer registry keys | |
4d59bff9 GG |
408 | DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\smartmontools" |
409 | DeleteRegKey HKLM "Software\smartmontools" | |
410 | ||
cfbba5b9 | 411 | ; Remove conf file ? |
4d59bff9 GG |
412 | IfFileExists "$INSTDIR\bin\smartd.conf" 0 noconf |
413 | ; Assume unchanged if timestamp is equal to sample file | |
414 | GetFileTime "$INSTDIR\bin\smartd.conf" $0 $1 | |
415 | GetFileTime "$INSTDIR\doc\smartd.conf" $2 $3 | |
416 | StrCmp "$0:$1" "$2:$3" +2 0 | |
417 | MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete configuration file$\n$INSTDIR\bin\smartd.conf ?" IDYES 0 IDNO noconf | |
418 | Delete "$INSTDIR\bin\smartd.conf" | |
419 | noconf: | |
420 | ||
cfbba5b9 | 421 | ; Remove log file ? |
4d59bff9 GG |
422 | IfFileExists "$INSTDIR\bin\smartd.log" 0 +3 |
423 | MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete log file$\n$INSTDIR\bin\smartd.log ?" IDYES 0 IDNO +2 | |
424 | Delete "$INSTDIR\bin\smartd.log" | |
425 | ||
cfbba5b9 GI |
426 | ; Remove drivedb-add file ? |
427 | IfFileExists "$INSTDIR\bin\drivedb-add.h" 0 +3 | |
428 | MessageBox MB_YESNO|MB_ICONQUESTION|MB_DEFBUTTON2 "Delete local drive database file$\n$INSTDIR\bin\drivedb-add.h ?" IDYES 0 IDNO +2 | |
429 | Delete "$INSTDIR\bin\drivedb-add.h" | |
430 | ||
4d59bff9 GG |
431 | ; Remove files |
432 | Delete "$INSTDIR\bin\smartctl.exe" | |
2127e193 | 433 | Delete "$INSTDIR\bin\smartctl-nc.exe" |
4d59bff9 GG |
434 | Delete "$INSTDIR\bin\smartd.exe" |
435 | Delete "$INSTDIR\bin\syslogevt.exe" | |
cfbba5b9 GI |
436 | Delete "$INSTDIR\bin\drivedb.h" |
437 | Delete "$INSTDIR\bin\drivedb.h.error" | |
438 | Delete "$INSTDIR\bin\drivedb.h.lastcheck" | |
439 | Delete "$INSTDIR\bin\drivedb.h.old" | |
440 | Delete "$INSTDIR\bin\update-smart-drivedb.exe" | |
4d59bff9 GG |
441 | Delete "$INSTDIR\bin\smartctl-run.bat" |
442 | Delete "$INSTDIR\bin\smartd-run.bat" | |
443 | Delete "$INSTDIR\bin\net-run.bat" | |
444 | Delete "$INSTDIR\doc\AUTHORS.txt" | |
445 | Delete "$INSTDIR\doc\CHANGELOG.txt" | |
446 | Delete "$INSTDIR\doc\COPYING.txt" | |
447 | Delete "$INSTDIR\doc\INSTALL.txt" | |
448 | Delete "$INSTDIR\doc\NEWS.txt" | |
449 | Delete "$INSTDIR\doc\README.txt" | |
450 | Delete "$INSTDIR\doc\TODO.txt" | |
451 | Delete "$INSTDIR\doc\WARNINGS.txt" | |
cfbba5b9 | 452 | Delete "$INSTDIR\doc\checksums.txt" |
4d59bff9 GG |
453 | Delete "$INSTDIR\doc\smartctl.8.html" |
454 | Delete "$INSTDIR\doc\smartctl.8.txt" | |
455 | Delete "$INSTDIR\doc\smartd.8.html" | |
456 | Delete "$INSTDIR\doc\smartd.8.txt" | |
457 | Delete "$INSTDIR\doc\smartd.conf" | |
458 | Delete "$INSTDIR\doc\smartd.conf.5.html" | |
459 | Delete "$INSTDIR\doc\smartd.conf.5.txt" | |
460 | Delete "$INSTDIR\uninst-smartmontools.exe" | |
461 | ||
462 | ; Remove shortcuts | |
a7e8ffec | 463 | SetShellVarContext all |
4d59bff9 GG |
464 | Delete "$SMPROGRAMS\smartmontools\*.*" |
465 | Delete "$SMPROGRAMS\smartmontools\Documentation\*.*" | |
466 | Delete "$SMPROGRAMS\smartmontools\smartctl Examples\*.*" | |
467 | Delete "$SMPROGRAMS\smartmontools\smartd Examples\*.*" | |
468 | ||
469 | ; Remove folders | |
470 | RMDir "$SMPROGRAMS\smartmontools\Documentation" | |
a37e7145 GG |
471 | RMDir "$SMPROGRAMS\smartmontools\smartctl Examples" |
472 | RMDir "$SMPROGRAMS\smartmontools\smartd Examples" | |
4d59bff9 GG |
473 | RMDir "$SMPROGRAMS\smartmontools" |
474 | RMDir "$INSTDIR\bin" | |
475 | RMDir "$INSTDIR\doc" | |
476 | RMDir "$INSTDIR" | |
477 | ||
478 | ; Remove install dir from PATH | |
479 | IfFileExists "$WINDIR\system32\cmd.exe" 0 +3 | |
480 | Push "$INSTDIR\bin" | |
481 | Call un.RemoveFromPath | |
482 | ||
a37e7145 GG |
483 | ; Remove drive menu registry entries |
484 | !insertmacro DriveMenuRemove | |
485 | ||
486 | ; Check for still existing entries | |
4d59bff9 GG |
487 | IfFileExists "$INSTDIR\bin\smartd.exe" 0 +3 |
488 | MessageBox MB_OK|MB_ICONEXCLAMATION "$INSTDIR\bin\smartd.exe could not be removed.$\nsmartd is possibly still running." | |
489 | Goto +3 | |
490 | IfFileExists "$INSTDIR" 0 +2 | |
491 | MessageBox MB_OK "Note: $INSTDIR could not be removed." | |
492 | ||
a37e7145 GG |
493 | IfFileExists "$SMPROGRAMS\smartmontools" 0 +2 |
494 | MessageBox MB_OK "Note: $SMPROGRAMS\smartmontools could not be removed." | |
495 | ||
4d59bff9 GG |
496 | SectionEnd |
497 | ||
498 | ;-------------------------------------------------------------------- | |
a37e7145 | 499 | ; Functions |
4d59bff9 GG |
500 | |
501 | Function .onInit | |
502 | ||
a37e7145 GG |
503 | ; Get UBCD4Win install location |
504 | ReadRegStr $0 HKLM "Software\UBCD4Win" "InstallPath" | |
505 | StrCmp $0 "" 0 +2 | |
506 | StrCpy $0 "C:\UBCD4Win" | |
507 | StrCpy $UBCDDIR "$0\plugin\Disk\Diagnostic\smartmontools" | |
508 | ||
4d59bff9 GG |
509 | ; Hide "Add install dir to PATH" on 9x/ME |
510 | IfFileExists "$WINDIR\system32\cmd.exe" +2 0 | |
a37e7145 | 511 | SectionSetText ${PATH_SECTION} "" |
4d59bff9 | 512 | |
a7e8ffec GI |
513 | Call ParseCmdLine |
514 | FunctionEnd | |
515 | ||
516 | ; Command line parsing | |
517 | !macro CheckCmdLineOption name section | |
518 | StrCpy $allopts "$allopts,${name}" | |
519 | Push ",$opts," | |
520 | Push ",${name}," | |
521 | Call StrStr | |
522 | Pop $0 | |
523 | StrCmp $0 "" 0 sel_${name} | |
524 | !insertmacro UnselectSection ${section} | |
525 | Goto done_${name} | |
526 | sel_${name}: | |
527 | !insertmacro SelectSection ${section} | |
528 | StrCpy $nomatch "" | |
529 | done_${name}: | |
530 | !macroend | |
531 | ||
532 | Function ParseCmdLine | |
533 | ; get /SO option | |
534 | Var /global opts | |
535 | ${GetParameters} $R0 | |
536 | ${GetOptions} $R0 "/SO" $opts | |
537 | IfErrors 0 +2 | |
538 | Return | |
539 | Var /global allopts | |
540 | StrCpy $allopts "" | |
541 | Var /global nomatch | |
542 | StrCpy $nomatch "t" | |
543 | ; turn sections on or off | |
544 | !insertmacro CheckCmdLineOption "smartctl" ${SMARTCTL_SECTION} | |
545 | !insertmacro CheckCmdLineOption "smartd" ${SMARTD_SECTION} | |
546 | !insertmacro CheckCmdLineOption "smartctlnc" ${SMARTCTL_NC_SECTION} | |
547 | !insertmacro CheckCmdLineOption "drivedb" ${DRIVEDB_SECTION} | |
548 | !insertmacro CheckCmdLineOption "doc" ${DOC_SECTION} | |
549 | !insertmacro CheckCmdLineOption "uninst" ${UNINST_SECTION} | |
550 | !insertmacro CheckCmdLineOption "menu" ${MENU_SECTION} | |
551 | !insertmacro CheckCmdLineOption "path" ${PATH_SECTION} | |
552 | !insertmacro CheckCmdLineOption "driveremove" ${DRIVE_REMOVE_SECTION} | |
553 | !insertmacro CheckCmdLineOption "drive0" ${DRIVE_0_SECTION} | |
554 | !insertmacro CheckCmdLineOption "drive1" ${DRIVE_1_SECTION} | |
555 | !insertmacro CheckCmdLineOption "drive2" ${DRIVE_2_SECTION} | |
556 | !insertmacro CheckCmdLineOption "drive3" ${DRIVE_3_SECTION} | |
557 | !insertmacro CheckCmdLineOption "drive4" ${DRIVE_4_SECTION} | |
558 | !insertmacro CheckCmdLineOption "drive5" ${DRIVE_5_SECTION} | |
559 | !insertmacro CheckCmdLineOption "ubcd" ${UBCD_SECTION} | |
560 | StrCmp $opts "-" done | |
561 | StrCmp $nomatch "" done | |
562 | StrCpy $0 "$allopts,-" "" 1 | |
563 | MessageBox MB_OK "Usage: smartmontools-VERSION.win32-setup [/S] [/SO component,...] [/D=INSTDIR]$\n$\ncomponents:$\n $0" | |
564 | Abort | |
565 | done: | |
4d59bff9 GG |
566 | FunctionEnd |
567 | ||
a37e7145 GG |
568 | ; Directory page callbacks |
569 | ||
570 | !macro CheckSection section | |
571 | SectionGetFlags ${section} $0 | |
572 | IntOp $0 $0 & 1 | |
573 | IntCmp $0 1 done | |
574 | !macroend | |
575 | ||
576 | Function SkipProgPath | |
577 | !insertmacro CheckSection ${SMARTCTL_SECTION} | |
2127e193 | 578 | !insertmacro CheckSection ${SMARTCTL_NC_SECTION} |
a37e7145 | 579 | !insertmacro CheckSection ${SMARTD_SECTION} |
cfbba5b9 | 580 | !insertmacro CheckSection ${DRIVEDB_SECTION} |
a37e7145 GG |
581 | !insertmacro CheckSection ${DOC_SECTION} |
582 | !insertmacro CheckSection ${MENU_SECTION} | |
583 | !insertmacro CheckSection ${PATH_SECTION} | |
584 | !insertmacro CheckSection ${DRIVE_0_SECTION} | |
585 | !insertmacro CheckSection ${DRIVE_1_SECTION} | |
586 | !insertmacro CheckSection ${DRIVE_2_SECTION} | |
587 | !insertmacro CheckSection ${DRIVE_3_SECTION} | |
588 | !insertmacro CheckSection ${DRIVE_4_SECTION} | |
589 | !insertmacro CheckSection ${DRIVE_5_SECTION} | |
590 | Abort | |
591 | done: | |
592 | FunctionEnd | |
593 | ||
594 | Function SkipUBCDPath | |
595 | !insertmacro CheckSection ${UBCD_SECTION} | |
596 | Abort | |
597 | done: | |
598 | FunctionEnd | |
599 | ||
600 | ||
601 | ; Create smartctl-run.bat | |
602 | ||
603 | Function CreateSmartctlBat | |
604 | Exch $0 | |
605 | FileOpen $0 $0 "w" | |
606 | FileWrite $0 '@echo off$\r$\nif not "%1" == "" goto run$\r$\n' | |
607 | FileWrite $0 'echo Examples (for first drive):$\r$\n' | |
608 | FileWrite $0 'echo smartctl -i sda Show identify information$\r$\n' | |
609 | FileWrite $0 'echo smartctl -H sda Show SMART health status$\r$\n' | |
610 | FileWrite $0 'echo smartctl -c sda Show SMART capabilities$\r$\n' | |
611 | FileWrite $0 'echo smartctl -A sda Show SMART attributes$\r$\n' | |
612 | FileWrite $0 'echo smartctl -l error sda Show error log$\r$\n' | |
613 | FileWrite $0 'echo smartctl -l selftest sda Show self-test log$\r$\n' | |
614 | FileWrite $0 'echo smartctl -a sda Show all of the above$\r$\n' | |
615 | FileWrite $0 'echo smartctl -t short sda Start short self test$\r$\n' | |
616 | FileWrite $0 'echo smartctl -t long sda Start long self test$\r$\n' | |
617 | FileWrite $0 'echo Use "sdb", "sdc", ... for second, third, ... drive.$\r$\n' | |
618 | FileWrite $0 'echo See man page (smartctl.8.*) for further info.$\r$\n' | |
619 | FileWrite $0 'goto end$\r$\n:run$\r$\n' | |
620 | FileWrite $0 'echo smartctl %1 %2 %3 %4 %5$\r$\n' | |
cfbba5b9 | 621 | FileWrite $0 '"$INSTDIR\bin\smartctl" %1 %2 %3 %4 %5$\r$\n' |
a37e7145 GG |
622 | FileWrite $0 'pause$\r$\n:end$\r$\n' |
623 | FileClose $0 | |
624 | Pop $0 | |
625 | FunctionEnd | |
626 | ||
cfbba5b9 GI |
627 | ; Create smartctl-run.bat if missing |
628 | ||
629 | Function CheckSmartctlBat | |
630 | IfFileExists "$INSTDIR\bin\smartctl-run.bat" done 0 | |
631 | SetOutPath "$INSTDIR\bin" | |
632 | DetailPrint "Create file: $INSTDIR\bin\smartctl-run.bat" | |
633 | Push "$INSTDIR\bin\smartctl-run.bat" | |
634 | Call CreateSmartctlBat | |
635 | done: | |
636 | FunctionEnd | |
637 | ||
4d59bff9 GG |
638 | |
639 | ;-------------------------------------------------------------------- | |
a37e7145 | 640 | ; Path functions |
4d59bff9 GG |
641 | ; |
642 | ; Based on example from: | |
643 | ; http://nsis.sourceforge.net/Path_Manipulation | |
644 | ; | |
645 | ||
646 | ||
647 | !include "WinMessages.nsh" | |
648 | ||
649 | ; Registry Entry for environment (NT4,2000,XP) | |
650 | ; All users: | |
651 | ;!define Environ 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' | |
652 | ; Current user only: | |
653 | !define Environ 'HKCU "Environment"' | |
654 | ||
655 | ||
656 | ; AddToPath - Appends dir to PATH | |
657 | ; (does not work on Win9x/ME) | |
658 | ; | |
659 | ; Usage: | |
660 | ; Push "dir" | |
661 | ; Call AddToPath | |
662 | ||
663 | Function AddToPath | |
664 | Exch $0 | |
665 | Push $1 | |
666 | Push $2 | |
667 | Push $3 | |
a37e7145 | 668 | |
4d59bff9 GG |
669 | ReadRegStr $1 ${Environ} "PATH" |
670 | Push "$1;" | |
671 | Push "$0;" | |
672 | Call StrStr | |
673 | Pop $2 | |
a37e7145 | 674 | StrCmp $2 "" 0 done |
4d59bff9 GG |
675 | Push "$1;" |
676 | Push "$0\;" | |
677 | Call StrStr | |
678 | Pop $2 | |
a37e7145 GG |
679 | StrCmp $2 "" 0 done |
680 | ||
4d59bff9 GG |
681 | DetailPrint "Add to PATH: $0" |
682 | StrCpy $2 $1 1 -1 | |
683 | StrCmp $2 ";" 0 +2 | |
684 | StrCpy $1 $1 -1 ; remove trailing ';' | |
685 | StrCmp $1 "" +2 ; no leading ';' | |
686 | StrCpy $0 "$1;$0" | |
687 | WriteRegExpandStr ${Environ} "PATH" $0 | |
688 | SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 | |
a37e7145 | 689 | |
4d59bff9 GG |
690 | done: |
691 | Pop $3 | |
692 | Pop $2 | |
693 | Pop $1 | |
694 | Pop $0 | |
695 | FunctionEnd | |
696 | ||
697 | ||
698 | ; RemoveFromPath - Removes dir from PATH | |
699 | ; | |
700 | ; Usage: | |
701 | ; Push "dir" | |
702 | ; Call RemoveFromPath | |
a37e7145 | 703 | |
4d59bff9 GG |
704 | Function un.RemoveFromPath |
705 | Exch $0 | |
706 | Push $1 | |
707 | Push $2 | |
708 | Push $3 | |
709 | Push $4 | |
710 | Push $5 | |
711 | Push $6 | |
a37e7145 | 712 | |
4d59bff9 GG |
713 | ReadRegStr $1 ${Environ} "PATH" |
714 | StrCpy $5 $1 1 -1 | |
715 | StrCmp $5 ";" +2 | |
716 | StrCpy $1 "$1;" ; ensure trailing ';' | |
717 | Push $1 | |
718 | Push "$0;" | |
719 | Call un.StrStr | |
720 | Pop $2 ; pos of our dir | |
721 | StrCmp $2 "" done | |
722 | ||
723 | DetailPrint "Remove from PATH: $0" | |
724 | StrLen $3 "$0;" | |
725 | StrLen $4 $2 | |
726 | StrCpy $5 $1 -$4 ; $5 is now the part before the path to remove | |
727 | StrCpy $6 $2 "" $3 ; $6 is now the part after the path to remove | |
728 | StrCpy $3 "$5$6" | |
729 | StrCpy $5 $3 1 -1 | |
730 | StrCmp $5 ";" 0 +2 | |
731 | StrCpy $3 $3 -1 ; remove trailing ';' | |
732 | WriteRegExpandStr ${Environ} "PATH" $3 | |
733 | SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 | |
734 | ||
735 | done: | |
736 | Pop $6 | |
737 | Pop $5 | |
738 | Pop $4 | |
739 | Pop $3 | |
740 | Pop $2 | |
741 | Pop $1 | |
742 | Pop $0 | |
743 | FunctionEnd | |
744 | ||
745 | ||
746 | ; StrStr - find substring in a string | |
747 | ; | |
748 | ; Usage: | |
749 | ; Push "this is some string" | |
750 | ; Push "some" | |
751 | ; Call StrStr | |
752 | ; Pop $0 ; "some string" | |
a37e7145 | 753 | |
4d59bff9 GG |
754 | !macro StrStr un |
755 | Function ${un}StrStr | |
756 | Exch $R1 ; $R1=substring, stack=[old$R1,string,...] | |
757 | Exch ; stack=[string,old$R1,...] | |
758 | Exch $R2 ; $R2=string, stack=[old$R2,old$R1,...] | |
759 | Push $R3 | |
760 | Push $R4 | |
761 | Push $R5 | |
762 | StrLen $R3 $R1 | |
763 | StrCpy $R4 0 | |
764 | ; $R1=substring, $R2=string, $R3=strlen(substring) | |
765 | ; $R4=count, $R5=tmp | |
766 | loop: | |
767 | StrCpy $R5 $R2 $R3 $R4 | |
768 | StrCmp $R5 $R1 done | |
769 | StrCmp $R5 "" done | |
770 | IntOp $R4 $R4 + 1 | |
771 | Goto loop | |
772 | done: | |
773 | StrCpy $R1 $R2 "" $R4 | |
774 | Pop $R5 | |
775 | Pop $R4 | |
776 | Pop $R3 | |
777 | Pop $R2 | |
778 | Exch $R1 ; $R1=old$R1, stack=[result,...] | |
779 | FunctionEnd | |
780 | !macroend | |
781 | !insertmacro StrStr "" | |
782 | !insertmacro StrStr "un." |