1 # sdcc.nsi - NSIS installer script for SDCC
3 # Copyright (c) 2003,2004 Borut Razem
5 # This file is part of sdcc.
7 # This software is provided 'as-is', without any express or implied
8 # warranty. In no event will the authors be held liable for any damages
9 # arising from the use of this software.
11 # Permission is granted to anyone to use this software for any purpose,
12 # including commercial applications, and to alter it and redistribute it
13 # freely, subject to the following restrictions:
15 # 1. The origin of this software must not be misrepresented; you must not
16 # claim that you wrote the original software. If you use this software
17 # in a product, an acknowledgment in the product documentation would be
18 # appreciated but is not required.
19 # 2. Altered source versions must be plainly marked as such, and must not be
20 # misrepresented as being the original software.
21 # 3. This notice may not be removed or altered from any source distribution.
24 # borut.razem@siol.net
26 # How to create WIN32 setup.exe
28 # - unpack WIN32 mingw daily snapshot sdcc-snapshot-i586-mingw32msvc-yyyymmdd.zip
29 # to a clean directory (the option to create directories should be enambled).
30 # A sub directory sdcc is created (referenced as PKGDIR in continuation).
31 # - copy files sdcc/support/scripts/sdcc.ico and sdcc/support/scripts/sdcc.nsi
32 # (this file) from the sdcc CVS snapshot to the PKGDIR directory
33 # - copy file COPYING from the sdcc CVS snapshot to the PKGDIR directory,
34 # rename it to COPYING.TXT and convert file COPYING to DOS format:
35 # unix2dos COPYING.TXT
36 # - run NSIS installer from PKGDIR directory:
37 # "c:\Program Files\NSIS\makensis.exe" sdcc.nsi
38 # - A setup file setup.exe is created in PKGDIR directory.
39 # Rename it to sdcc_yyyymmdd_setup.exe and upload it
40 # to sdcc download repository at sourceforge.net
43 # How to upload secc setup.exe tosourceforge.net
45 # Execute following commands from the cmd prompt:
46 # - sftp sdcc.sourceforge.net
47 # - cd /home/groups/s/sd/sdcc/htdocs/snapshots/i586-mingw32msvc-setup
48 # - put sdcc_yyyymmdd_setup.exe
58 !define DEV_ROOT "${SDCC_ROOT}"
60 !system "unix2dos ${SDCC_ROOT}\doc\ChangeLog_head.txt" = 0
61 !system "unix2dos ${SDCC_ROOT}\doc\README.TXT" = 0
63 InstType "Full (Bin, Doc, Lib, Src)"
64 InstType "Medium (Bin, Doc, Lib)"
65 InstType "Compact (Bin, Doc)"
67 ;--------------------------------
70 Var MUI_STARTMENUPAGE_VARIABLE
72 ;--------------------------------
73 !define MUI_ABORTWARNING
75 !insertmacro MUI_PAGE_WELCOME
76 !insertmacro MUI_PAGE_LICENSE "${SDCC_ROOT}\COPYING.TXT"
77 !define MUI_STARTMENUPAGE_DEFAULTFOLDER "SDCC"
78 !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM"
79 !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC"
80 !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "NSIS:StartMenuDir"
81 !define MUI_STARTMENUPAGE_NODISABLE
82 !insertmacro MUI_PAGE_STARTMENU Application $MUI_STARTMENUPAGE_VARIABLE
83 !insertmacro MUI_PAGE_COMPONENTS
84 !insertmacro MUI_PAGE_DIRECTORY
85 !insertmacro MUI_PAGE_INSTFILES
86 !insertmacro MUI_PAGE_FINISH
88 !insertmacro MUI_UNPAGE_INSTFILES
90 !insertmacro MUI_LANGUAGE "English"
95 InstallDir "$PROGRAMFILES\SDCC"
97 ShowUnInstDetails show
100 ;Uninstall the old version, if present
101 ReadRegStr $R0 HKLM \
102 "Software\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" \
106 MessageBox MB_OKCANCEL|MB_ICONEXCLAMATION \
107 "$(^Name) is already installed. $\n$\nClick 'OK' to remove the \
108 previous version or 'Cancel' to cancel this upgrade." \
113 ; Run the uninstaller
115 ExecWait '$R0 _?=$INSTDIR' ;Do not copy the uninstaller to a temp file
117 ;IfErrors no_remove_uninstaller
118 ; ;You can either use Delete /REBOOTOK in the uninstaller or add some code
119 ; ;here to remove to remove the uninstaller. Use a registry key to check
120 ; ;whether the user has chosen to uninstall. If you are using an uninstaller
121 ; ;components page, make sure all sections are uninstalled.
122 ;no_remove_uninstaller:
127 ; Install the new version
128 MessageBox MB_YESNO|MB_ICONQUESTION "This will install $(^Name). Do you wish to continue?" IDYES +2
135 SetOutPath "$INSTDIR"
137 File "${SDCC_ROOT}\COPYING.TXT"
140 Section "SDCC application files"
142 SetOutPath "$INSTDIR\bin"
143 File "${SDCC_ROOT}\bin\*.exe"
146 Section "SDCC documentation"
148 SetOutPath "$INSTDIR\doc"
149 File "${SDCC_ROOT}\doc\ChangeLog_head.txt"
150 File "${SDCC_ROOT}\doc\README.TXT"
153 Section "SDCC include files"
155 SetOutPath "$INSTDIR\include\asm\default"
156 File "${DEV_ROOT}\include\asm\default\features.h"
157 SetOutPath "$INSTDIR\include\asm\ds390"
158 File "${DEV_ROOT}\include\asm\ds390\features.h"
159 SetOutPath "$INSTDIR\include\asm\gbz80"
160 File "${DEV_ROOT}\include\asm\gbz80\features.h"
161 SetOutPath "$INSTDIR\include\asm\mcs51"
162 File "${DEV_ROOT}\include\asm\mcs51\features.h"
163 SetOutPath "$INSTDIR\include\asm\pic16"
164 File "${DEV_ROOT}\include\asm\pic16\features.h"
165 SetOutPath "$INSTDIR\include\asm\z80"
166 File "${DEV_ROOT}\include\asm\z80\features.h"
167 SetOutPath "$INSTDIR\include\hc08"
168 File "${DEV_ROOT}\include\hc08\*.h"
169 SetOutPath "$INSTDIR\include\mcs51"
170 File "${DEV_ROOT}\include\mcs51\*.h"
171 SetOutPath "$INSTDIR\include\pic16"
172 File "${DEV_ROOT}\include\pic16\*.h"
173 SetOutPath "$INSTDIR\include\z80"
174 File "${DEV_ROOT}\include\z80\*.h"
175 SetOutPath "$INSTDIR\include"
176 File "${DEV_ROOT}\include\*.h"
179 Section "SDCC DS390 library"
181 SetOutPath "$INSTDIR\lib\ds390"
182 File "${DEV_ROOT}\lib\ds390\*.asm"
183 File "${DEV_ROOT}\lib\ds390\*.rel"
184 File "${DEV_ROOT}\lib\ds390\*.lib"
187 Section "SDCC DS400 library"
189 SetOutPath "$INSTDIR\lib\ds400"
190 File "${DEV_ROOT}\lib\ds400\*.asm"
191 File "${DEV_ROOT}\lib\ds400\*.rel"
192 File "${DEV_ROOT}\lib\ds400\*.lib"
195 Section "SDCC GBZ80 library"
197 SetOutPath "$INSTDIR\lib\gbz80"
198 File "${DEV_ROOT}\lib\gbz80\*.asm"
199 File "${DEV_ROOT}\lib\gbz80\*.o"
200 File "${DEV_ROOT}\lib\gbz80\*.lib"
203 Section "SDCC Z80 library"
205 SetOutPath "$INSTDIR\lib\z80"
206 File "${DEV_ROOT}\lib\z80\*.asm"
207 File "${DEV_ROOT}\lib\z80\*.o"
208 File "${DEV_ROOT}\lib\z80\*.lib"
211 Section "SDCC large model library"
213 SetOutPath "$INSTDIR\lib\large"
214 File "${DEV_ROOT}\lib\large\*.asm"
215 File "${DEV_ROOT}\lib\large\*.rel"
216 File "${DEV_ROOT}\lib\large\*.lib"
219 Section "SDCC small model library"
221 SetOutPath "$INSTDIR\lib\small"
222 File "${DEV_ROOT}\lib\small\*.asm"
223 File "${DEV_ROOT}\lib\small\*.rel"
224 File "${DEV_ROOT}\lib\small\*.lib"
227 Section "SDCC HC08 library"
229 SetOutPath "$INSTDIR\lib\hc08"
230 File "${DEV_ROOT}\lib\hc08\*.asm"
231 File "${DEV_ROOT}\lib\hc08\*.rel"
232 File "${DEV_ROOT}\lib\hc08\*.lib"
235 Section "SDCC PIC16 library"
237 SetOutPath "$INSTDIR\lib\pic16"
238 File "${DEV_ROOT}\lib\pic16\*.o"
239 File "${DEV_ROOT}\lib\pic16\*.lib"
242 Section "SDCC PIC library"
244 SetOutPath "$INSTDIR\lib\pic"
245 File "${DEV_ROOT}\lib\pic\*.lib"
248 Section "SDCC library sources"
250 SetOutPath "$INSTDIR\lib\src\ds390\examples"
251 File "${DEV_ROOT}\lib\src\ds390\examples\MOVED"
253 SetOutPath "$INSTDIR\lib\src\ds390"
254 File "${DEV_ROOT}\lib\src\ds390\*.c"
255 File "${DEV_ROOT}\lib\src\ds390\libds390.lib"
256 File "${DEV_ROOT}\lib\src\ds390\Makefile"
257 File "${DEV_ROOT}\lib\src\ds390\Makefile.dep"
259 SetOutPath "$INSTDIR\lib\src\ds400"
260 File "${DEV_ROOT}\lib\src\ds400\*.c"
261 File "${DEV_ROOT}\lib\src\ds400\libds400.lib"
262 File "${DEV_ROOT}\lib\src\ds400\Makefile"
263 File "${DEV_ROOT}\lib\src\ds400\Makefile.dep"
265 SetOutPath "$INSTDIR\lib\src\gbz80"
266 File "${DEV_ROOT}\lib\src\gbz80\*.c"
267 File "${DEV_ROOT}\lib\src\gbz80\*.s"
268 File "${DEV_ROOT}\lib\src\gbz80\gbz80.lib"
269 File "${DEV_ROOT}\lib\src\gbz80\Makefile"
270 File "${DEV_ROOT}\lib\src\gbz80\README"
272 SetOutPath "$INSTDIR\lib\src\z80"
273 File "${DEV_ROOT}\lib\src\z80\*.c"
274 File "${DEV_ROOT}\lib\src\z80\*.s"
275 File "${DEV_ROOT}\lib\src\z80\Makefile"
276 File "${DEV_ROOT}\lib\src\z80\README"
277 File "${DEV_ROOT}\lib\src\z80\z80.lib"
279 SetOutPath "$INSTDIR\lib\src\hc08"
280 File "${DEV_ROOT}\lib\src\hc08\*.c"
281 File "${DEV_ROOT}\lib\src\hc08\Makefile"
282 File "${DEV_ROOT}\lib\src\hc08\hc08.lib"
284 SetOutPath "$INSTDIR\lib\src"
285 File "${DEV_ROOT}\lib\src\*.c"
289 !insertmacro MUI_STARTMENU_WRITE_BEGIN Application
290 CreateDirectory "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE"
291 CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\SDCC on the Web.lnk" "$INSTDIR\sdcc.url"
292 CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Uninstall SDCC.lnk" "$INSTDIR\uninstall.exe"
293 CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Documentation.lnk" "$INSTDIR\doc\README.TXT" "" "$INSTDIR\sdcc.ico" "" "" "" ""
294 CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Change Log.lnk" "$INSTDIR\doc\ChangeLog_head.txt" "" "$INSTDIR\sdcc.ico" "" "" "" ""
295 CreateShortCut "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\GPL 2 License.lnk" "$INSTDIR\COPYING.TXT"
296 !insertmacro MUI_STARTMENU_WRITE_END
300 WriteIniStr "$INSTDIR\sdcc.url" "InternetShortcut" "URL" "http://sdcc.sourceforge.net/"
304 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "DisplayName" "SDCC"
305 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "UninstallString" "$INSTDIR\uninstall.exe"
306 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "Publisher" "sdcc.sourceforge.net"
307 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "URLInfoAbout" "http://sdcc.sourceforge.net/"
308 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "HelpLink" "http://sdcc.sourceforge.net/"
309 WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "URLUpdateInfo" "http://sdcc.sourceforge.net/"
310 WriteUninstaller "$INSTDIR\uninstall.exe"
314 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Do you want to add $INSTDIR\bin to the PATH?" IDNO +3
320 ;;;; Uninstaller code ;;;;
323 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Are you sure you want to completely remove $(^Name) and all of its components?" IDYES +2
327 Function un.onUninstSuccess
329 MessageBox MB_ICONINFORMATION|MB_OK "$(^Name) was successfully removed from your computer."
333 !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_STARTMENUPAGE_VARIABLE
335 Delete "$INSTDIR\sdcc.url"
337 DeleteRegValue HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC" "NSIS:StartMenuDir"
338 DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\SDCC"
340 Delete "$INSTDIR\uninstall.exe"
341 Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\GPL 2 License.lnk"
342 Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Change Log.lnk"
343 Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Documentation.lnk"
344 Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\Uninstall SDCC.lnk"
345 Delete "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE\SDCC on the Web.lnk"
347 Delete "$INSTDIR\lib\src\hc08\*.c"
348 Delete "$INSTDIR\lib\src\hc08\hc08.lib"
349 Delete "$INSTDIR\lib\src\hc08\Makefile"
351 Delete "$INSTDIR\lib\src\z80\*.c"
352 Delete "$INSTDIR\lib\src\z80\*.s"
353 Delete "$INSTDIR\lib\src\z80\z80.lib"
354 Delete "$INSTDIR\lib\src\z80\README"
355 Delete "$INSTDIR\lib\src\z80\Makefile"
357 Delete "$INSTDIR\lib\src\gbz80\*.c"
358 Delete "$INSTDIR\lib\src\gbz80\*.s"
359 Delete "$INSTDIR\lib\src\gbz80\gbz80.lib"
360 Delete "$INSTDIR\lib\src\gbz80\README"
361 Delete "$INSTDIR\lib\src\gbz80\Makefile"
363 Delete "$INSTDIR\lib\src\ds390\*.c"
364 Delete "$INSTDIR\lib\src\ds390\libds390.lib"
365 Delete "$INSTDIR\lib\src\ds390\Makefile.dep"
366 Delete "$INSTDIR\lib\src\ds390\Makefile"
367 Delete "$INSTDIR\lib\src\ds390\examples\MOVED"
369 Delete "$INSTDIR\lib\src\ds400\*.c"
370 Delete "$INSTDIR\lib\src\ds400\libds400.lib"
371 Delete "$INSTDIR\lib\src\ds400\Makefile.dep"
372 Delete "$INSTDIR\lib\src\ds400\Makefile"
374 Delete "$INSTDIR\lib\src\*.c"
376 Delete "$INSTDIR\lib\pic\*.lib"
378 Delete "$INSTDIR\lib\pic16\*.o"
379 Delete "$INSTDIR\lib\pic16\*.lib"
381 Delete "$INSTDIR\lib\hc08\*.rel"
382 Delete "$INSTDIR\lib\hc08\*.asm"
383 Delete "$INSTDIR\lib\hc08\*.lib"
385 Delete "$INSTDIR\lib\z80\*.o"
386 Delete "$INSTDIR\lib\z80\*.asm"
387 Delete "$INSTDIR\lib\z80\*.lib"
389 Delete "$INSTDIR\lib\small\*.asm"
390 Delete "$INSTDIR\lib\small\*.rel"
391 Delete "$INSTDIR\lib\small\*.lib"
393 Delete "$INSTDIR\lib\large\*.asm"
394 Delete "$INSTDIR\lib\large\*.rel"
395 Delete "$INSTDIR\lib\large\*.lib"
397 Delete "$INSTDIR\lib\gbz80\*.asm"
398 Delete "$INSTDIR\lib\gbz80\*.o"
399 Delete "$INSTDIR\lib\gbz80\*.lib"
401 Delete "$INSTDIR\lib\ds390\*.asm"
402 Delete "$INSTDIR\lib\ds390\*.rel"
403 Delete "$INSTDIR\lib\ds390\*.lib"
405 Delete "$INSTDIR\lib\ds400\*.asm"
406 Delete "$INSTDIR\lib\ds400\*.rel"
407 Delete "$INSTDIR\lib\ds400\*.lib"
409 Delete "$INSTDIR\include\asm\z80\*.h"
410 Delete "$INSTDIR\include\asm\pic16\*.h"
411 Delete "$INSTDIR\include\asm\mcs51\*.h"
412 Delete "$INSTDIR\include\asm\gbz80\*.h"
413 Delete "$INSTDIR\include\asm\ds390\*.h"
414 Delete "$INSTDIR\include\asm\default\*.h"
415 Delete "$INSTDIR\include\z80\*.h"
416 Delete "$INSTDIR\include\pic16\*.h"
417 Delete "$INSTDIR\include\mcs51\*.h"
418 Delete "$INSTDIR\include\hc08\*.h"
419 Delete "$INSTDIR\include\*.h"
421 Delete "$INSTDIR\doc\README.TXT"
422 Delete "$INSTDIR\doc\ChangeLog_head.txt"
424 Delete "$INSTDIR\bin\*.exe"
426 Delete "$INSTDIR\COPYING.TXT"
427 Delete "$INSTDIR\sdcc.ico"
429 RMDir "$SMPROGRAMS\$MUI_STARTMENUPAGE_VARIABLE"
431 RMDir "$INSTDIR\lib\src\z80"
432 RMDir "$INSTDIR\lib\src\gbz80"
433 RMDir "$INSTDIR\lib\src\ds390\examples"
434 RMDir "$INSTDIR\lib\src\ds390"
435 RMDir "$INSTDIR\lib\src\ds400"
436 RMDir "$INSTDIR\lib\src\hc08"
437 RMDir "$INSTDIR\lib\src"
439 RMDir "$INSTDIR\lib\pic"
440 RMDir "$INSTDIR\lib\pic16"
441 RMDir "$INSTDIR\lib\z80"
442 RMDir "$INSTDIR\lib\small"
443 RMDir "$INSTDIR\lib\large"
444 RMDir "$INSTDIR\lib\gbz80"
445 RMDir "$INSTDIR\lib\ds390"
446 RMDir "$INSTDIR\lib\ds400"
447 RMDir "$INSTDIR\lib\hc08"
450 RMDir "$INSTDIR\include\asm\z80"
451 RMDir "$INSTDIR\include\asm\pic16"
452 RMDir "$INSTDIR\include\asm\mcs51"
453 RMDir "$INSTDIR\include\asm\gbz80"
454 RMDir "$INSTDIR\include\asm\ds390"
455 RMDir "$INSTDIR\include\asm\default"
456 RMDir "$INSTDIR\include\asm"
457 RMDir "$INSTDIR\include\z80"
458 RMDir "$INSTDIR\include\pic16"
459 RMDir "$INSTDIR\include\mcs51"
460 RMDir "$INSTDIR\include\hc08"
461 RMDir "$INSTDIR\include"
470 Call un.RemoveFromPath
475 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
476 ; Path Manipulation functions ;
477 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
480 !include "WinMessages.nsh"
483 ; AddToPath - Adds the given dir to the search path.
484 ; Input - head of the stack
485 ; Note - Win9x systems requires reboot
494 ; don't add if the path doesn't exist
495 IfFileExists $0 "" AddToPath_done
500 ; Not on NT: read PATH from environment variable
503 ; On NT: read PATH from registry
504 ReadRegStr $1 HKCU "Environment" "PATH"
509 StrCmp $2 "" "" AddToPath_done
514 StrCmp $2 "" "" AddToPath_done
515 GetFullPathName /SHORT $3 $0
520 StrCmp $2 "" "" AddToPath_done
525 StrCmp $2 "" "" AddToPath_done
527 StrCmp $4 1 AddToPath_NT
530 FileOpen $1 "$1\autoexec.bat" a
533 IntCmp $2 26 0 +2 +2 ; DOS EOF
534 FileSeek $1 -1 END ; write over EOF
535 FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n"
541 ReadRegStr $1 HKCU "Environment" "PATH"
542 StrCpy $2 $1 1 -1 ; copy last char
543 StrCmp $2 ";" 0 +2 ; if last char == ;
544 StrCpy $1 $1 -1 ; remove last char
545 StrCmp $1 "" AddToPath_NTdoIt
548 WriteRegExpandStr HKCU "Environment" "PATH" $0
549 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
559 ; RemoveFromPath - Remove a given dir from the path
560 ; Input: head of the stack
562 Function un.RemoveFromPath
571 IntFmt $6 "%c" 26 ; DOS EOF
575 StrCmp $1 1 unRemoveFromPath_NT
578 FileOpen $1 "$1\autoexec.bat" r
581 GetFullPathName /SHORT $0 $0
582 StrCpy $0 "SET PATH=%PATH%;$0"
583 Goto unRemoveFromPath_dosLoop
585 unRemoveFromPath_dosLoop:
587 StrCpy $5 $3 1 -1 ; read last char
588 StrCmp $5 $6 0 +2 ; if DOS EOF
589 StrCpy $3 $3 -1 ; remove DOS EOF so we can compare
590 StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine
591 StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine
592 StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine
593 StrCmp $3 "" unRemoveFromPath_dosLoopEnd
595 Goto unRemoveFromPath_dosLoop
596 unRemoveFromPath_dosLoopRemoveLine:
598 Goto unRemoveFromPath_dosLoop
600 unRemoveFromPath_dosLoopEnd:
604 Delete "$1\autoexec.bat"
605 CopyFiles /SILENT $4 "$1\autoexec.bat"
607 Goto unRemoveFromPath_done
610 ReadRegStr $1 HKCU "Environment" "PATH"
611 StrCpy $5 $1 1 -1 ; copy last char
612 StrCmp $5 ";" +2 ; if last char != ;
613 StrCpy $1 "$1;" ; append ;
616 Call un.StrStr ; Find `$0;` in $1
617 Pop $2 ; pos of our dir
618 StrCmp $2 "" unRemoveFromPath_done
619 ; else, it is in path
624 StrCpy $5 $1 -$4 ; $5 is now the part before the path to remove
625 StrCpy $6 $2 "" $3 ; $6 is now the part after the path to remove
628 StrCpy $5 $3 1 -1 ; copy last char
629 StrCmp $5 ";" 0 +2 ; if last char == ;
630 StrCpy $3 $3 -1 ; remove last char
633 ; New PATH not empty: update the registry
634 WriteRegExpandStr HKCU "Environment" "PATH" $3
636 ; New PATH empty: remove from the registry
637 DeleteRegValue HKCU "Environment" "PATH"
638 SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000
640 unRemoveFromPath_done:
650 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
651 ; Utility Functions ;
652 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
656 ; output, top of the stack = 1 if NT or 0 if not
661 ; ($R0 at this point is 1 or 0)
666 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion
667 StrCmp $0 "" 0 IsNT_yes
680 !insertmacro IsNT "un."
683 ; input, top of stack = string to search for
684 ; top of stack-1 = string to search in
685 ; output, top of stack (replaces with the portion of the string remaining)
686 ; modifies no other variables.
689 ; Push "this is a long ass string"
693 ; ($R0 at this point is "ass string")
697 Exch $R1 ; st=haystack,old$R1, $R1=needle
698 Exch ; st=old$R1,haystack
699 Exch $R2 ; st=old$R1,old$R2, $R2=haystack
711 StrCpy $R5 $R2 $R3 $R4
717 StrCpy $R1 $R2 "" $R4
725 !insertmacro StrStr ""
726 !insertmacro StrStr "un."