/
dinstaller.nsi
650 lines (472 loc) · 19.6 KB
/
dinstaller.nsi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
; Release Manager:
; Please use the special build of NSIS that supports large strings.
; Updating the PATH will often not work or work incorrectly with the
; regular build of NSIS.
;
; http://nsis.sourceforge.net/Special_Builds
;--------------------------------------------------------
; Defines
;--------------------------------------------------------
; Installer Type
; --------------
; Download zip from website. Comment out to embed zip instead (be sure to set
; paths below).
!define Download
; Versions
; --------
; D2
; The version will be pulled from the VERSION file in the dmd
; repository. Change the path to match.
!define D2VersionPath "..\..\dmd\VERSION"
!ifndef Version2
!define /file Version2 ${D2VersionPath}
!endif
; or manually the verison manually:
;!define Version2 "2.065"
!define Version2ReleaseYear "2014" ; S3 file hosting includes the year in the URL so update this as needed
; D1
!define Version1 "1.076"
!define Version1ReleaseYear "2013" ; S3 file hosting includes the year in the URL so update this as needed
; DMC
!define VersionDMC "857"
; Extras
!define VersionCurl "7.34.0"
!define VersionVisualD "0.3.38-1"
; URLS
; ----
!define BaseURL "http://downloads.dlang.org"
!define BaseURLAlt "http://ftp.digitalmars.com"
!define VisualDBaseURL "https://github.com/D-Programming-Language/visuald/releases/download"
; The URLs to the release zips (used when Download is defined)
!define DownloadDmd1ZipUrl "${BaseURL}/releases/${Version1ReleaseYear}/dmd.${Version1}.zip"
!define DownloadDmd2ZipUrl "${BaseURL}/releases/${Version2ReleaseYear}/dmd.${Version2}.zip"
!define DownloadDmd2ZipUrlAlt "${BaseURLAlt}/dmd.${Version2}.zip"
!define DownloadDmcZipUrl "${BaseURL}/other/dm${VersionDMC}c.zip"
!define DownloadCurlZipUrl "${BaseURL}/other/libcurl-${VersionCurl}-WinSSL-zlib-x86-x64.zip"
!define DownloadVisualDUrl "${VisualDBaseURL}/v${VersionVisualD}/VisualD-v${VersionVisualD}.exe"
; The paths to the release zips (used when Download isn't defined)
!define DmdZipPath1 "dmd.${Version1}.zip"
!define DmdZipPath2 "dmd.${Version2}.zip"
!define DmcZipPath "dm${VersionDMC}c.zip"
!define CurlZipPath "libcurl-${VersionCurl}-WinSSL-zlib-x86-x64.zip"
!define VisualDPath "VisualD-v${VersionVisualD}.exe"
!define DPublisher "Digital Mars"
!define DName "DMD"
!define ARP "Software\Microsoft\Windows\CurrentVersion\Uninstall\${DName}"
;--------------------------------------------------------
; Includes
;--------------------------------------------------------
!include "MUI.nsh"
!include "EnvVarUpdate.nsh"
!include "ReplaceInFile.nsh"
!include "FileFunc.nsh"
;------------------------------------------------------------
; Variables
;------------------------------------------------------------
Var I
Var J
Var K
Var InstanceCheck
;--------------------------------------------------------
; General definitions
;--------------------------------------------------------
; Name of the installer
Name "D Programming Language"
; Name of the output file of the installer
OutFile "dmd-${Version2}.exe"
!define InstallerFilename "dmd-${Version2}.exe"
; Where the program will be installed
InstallDir "C:\D"
; Take the installation directory from the registry, if possible
InstallDirRegKey HKCU "Software\${DName}" "InstallationFolder"
; This is so no one can corrupt the installer
CRCCheck force
;------------------------------------------------------------
; Macros definition
;------------------------------------------------------------
; Check if a dmd installer instance is already running
!macro OneInstanceOnly
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "digital_mars_d_compiler_installer") ?e'
Pop $R0
StrCmp $R0 0 +3
MessageBox MB_OK|MB_ICONSTOP "An instance of DMD installer is already running"
Abort
!macroend
;--------------------------------------------------------
; Interface settings
;--------------------------------------------------------
; Confirmation when exiting the installer
!define MUI_ABORTWARNING
!define MUI_ICON "installer-icon.ico"
!define MUI_UNICON "uninstaller-icon.ico"
;--------------------------------------------------------
; Language selection dialog settings
;--------------------------------------------------------
; Remember the installation language
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!define MUI_LANGDLL_REGISTRY_KEY "Software\D"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"
;--------------------------------------------------------
; Installer pages
;--------------------------------------------------------
!define MUI_WELCOMEFINISHPAGE_BITMAP "installer_image.bmp"
!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH
!insertmacro MUI_UNPAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_UNPAGE_FINISH
;--------------------------------------------------------
; The languages
;--------------------------------------------------------
!insertmacro MUI_LANGUAGE "English"
;!insertmacro MUI_LANGUAGE "Spanish"
; Reserve files needed by the installation
!insertmacro MUI_RESERVEFILE_LANGDLL
;--------------------------------------------------------
; Sections
;--------------------------------------------------------
SectionGroup /e "D2"
Section "-D2" Dmd2Files
; This section is mandatory
SectionIn RO
SetOutPath $INSTDIR
; Create installation directory
CreateDirectory "$INSTDIR"
!ifdef Download
; Download the zip files
inetc::get /caption "Downloading dmd.${Version2}.zip..." /popup "" "${DownloadDmd2ZipUrl}" "$INSTDIR\dmd2.zip" /end
Pop $R0
StrCmp $R0 "OK" done
inetc::get /caption "Downloading dmd.${Version2}.zip..." /popup "" "${DownloadDmd2ZipUrlAlt}" "$INSTDIR\dmd2.zip" /end
Pop $R0
StrCmp $R0 "OK" done
MessageBox MB_OK|MB_ICONSTOP "Failed to download dmd.${Version2}.zip"
done:
!else
FILE "/oname=$INSTDIR\dmd2.zip" "${DmdZipPath2}"
!endif
; Unzip them right there
nsisunz::Unzip "$INSTDIR\dmd2.zip" "$INSTDIR"
; Delete the zip files
Delete "$INSTDIR\dmd2.zip"
; Create 32-bit command line batch file
FileOpen $0 "$INSTDIR\dmd2vars32.bat" w
FileWrite $0 "@echo.$\n"
FileWrite $0 "@echo Setting up 32-bit environment for using DMD 2 from %~dp0dmd2\windows\bin.$\n"
FileWrite $0 "@set PATH=%~dp0dmd2\windows\bin;%PATH%$\n"
FileClose $0
; Create 64-bit command line batch file
FileOpen $0 "$INSTDIR\dmd2vars64.bat" w
FileWrite $0 "@echo.$\n"
FileWrite $0 "@echo Setting up 64-bit environment for using DMD 2 from %~dp0dmd2\windows\bin.$\n"
FileWrite $0 "@echo.$\n"
FileWrite $0 "@echo dmd must still be called with -m64 in order to generate 64-bit code.$\n"
FileWrite $0 "@echo This command prompt adds the path of extra 64-bit DLLs so generated programs$\n"
FileWrite $0 "@echo which use the extra DLLs (notably libcurl) can be executed.$\n"
FileWrite $0 "@set PATH=%~dp0dmd2\windows\bin;%PATH%$\n"
FileWrite $0 "@set PATH=%~dp0dmd2\windows\bin64;%PATH%$\n"
FileClose $0
; Write installation dir in the registry
WriteRegStr HKLM "SOFTWARE\${DName}" "InstallationFolder" "$INSTDIR"
; Registry keys for dmd uninstaller
WriteRegStr HKLM "${ARP}" "DisplayName" "${DName}"
WriteRegStr HKLM "${ARP}" "DisplayVersion" "${Version2}"
WriteRegStr HKLM "${ARP}" "UninstallString" "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "${ARP}" "DisplayIcon" "$INSTDIR\uninstall.exe"
WriteRegStr HKLM "${ARP}" "Publisher" "${DPublisher}"
WriteRegStr HKLM "${ARP}" "HelpLink" "http://dlang.org/"
WriteRegDWORD HKLM "${ARP}" "NoModify" 1
WriteRegDWORD HKLM "${ARP}" "NoRepair" 1
WriteUninstaller "uninstall.exe"
SectionEnd
Section "cURL support" cURLFiles
; This section is mandatory
;SectionIn RO
SetOutPath $INSTDIR
; Create installation directory
CreateDirectory "$INSTDIR"
!ifdef Download
; Download the zip files
inetc::get /caption "Downloading ${CurlZipPath}..." /popup "" "${DownloadCurlZipUrl}" "$INSTDIR\curl.zip" /end
Pop $0 # return value = exit code, "OK" means OK
!else
FILE "/oname=$INSTDIR\curl.zip" "${CurlZipPath}"
!endif
; Unzip them right there
nsisunz::Unzip "$INSTDIR\curl.zip" "$INSTDIR"
; Delete the zip files
Delete "$INSTDIR\curl.zip"
SectionEnd
Section "Detect MSVC" DetectMSVC
ClearErrors
ReadRegStr $0 HKLM "Software\Microsoft\VisualStudio\12.0\Setup\VC" "ProductDir"
StrCpy $1 ";VC2013 "
IfErrors 0 write_vc_path
ClearErrors
ReadRegStr $0 HKLM "Software\Microsoft\VisualStudio\11.0\Setup\VC" "ProductDir"
StrCpy $1 ";VC2012 "
IfErrors 0 write_vc_path
ClearErrors
ReadRegStr $0 HKLM "Software\Microsoft\VisualStudio\10.0\Setup\VC" "ProductDir"
StrCpy $1 ";VC2010 "
IfErrors 0 write_vc_path
ClearErrors
ReadRegStr $0 HKLM "Software\Microsoft\VisualStudio\9.0\Setup\VC" "ProductDir"
StrCpy $1 ";VC2008 "
IfErrors no_vc_detected write_vc_path
write_vc_path:
!insertmacro _ReplaceInFile "$INSTDIR\dmd2\windows\bin\sc.ini" ";VCINSTALLDIR=" "VCINSTALLDIR=$0"
!insertmacro _ReplaceInFile "$INSTDIR\dmd2\windows\bin\sc.ini" "$1" ""
goto finish_vc_path
no_vc_detected:
MessageBox MB_OK "Could not detect Visual Studio (2008-2013 are supported). Using defaults."
finish_vc_path:
ClearErrors
ReadRegStr $0 HKLM "Software\Microsoft\Windows Kits\Installed Roots" "KitsRoot81"
IfErrors 0 write_sdk_path
ClearErrors
ReadRegStr $0 HKLM "Software\Microsoft\Windows Kits\Installed Roots" "KitsRoot" ; 8.0
IfErrors 0 write_sdk_path
ClearErrors
ReadRegStr $0 HKLM "Software\Microsoft\Microsoft SDKs\Windows\v7.1A" "InstallationFolder"
IfErrors 0 write_sdk_path
ClearErrors
ReadRegStr $0 HKLM "Software\Microsoft\Microsoft SDKs\Windows\v7.0A" "InstallationFolder"
IfErrors 0 write_sdk_path
ClearErrors
ReadRegStr $0 HKLM "Software\Microsoft\Microsoft SDKs\Windows\v6.0A" "InstallationFolder"
IfErrors no_sdk_detected write_sdk_path
write_sdk_path:
!insertmacro _ReplaceInFile "$INSTDIR\dmd2\windows\bin\sc.ini" ";WindowsSdkDir=" "WindowsSdkDir=$0"
goto finish_sdk_path
no_sdk_detected:
MessageBox MB_OK "Could not detect Windows SDK (6.0A-8.1 are supported). Using defaults."
finish_sdk_path:
ClearErrors
SectionEnd
Section "Add to PATH" AddD2ToPath
; Add dmd 2 directories to path (for all users)
SectionGetFlags ${Dmd2Files} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} +1 +2
${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\dmd2\windows\bin"
SectionEnd
SectionGroupEnd
SectionGroup "D1"
Section /o "-D1" Dmd1Files
; This section is mandatory
;SectionIn RO
SetOutPath $INSTDIR
; Create installation directory
CreateDirectory "$INSTDIR"
!ifdef Download
; Download the zip files
inetc::get /caption "Downloading dmd.${Version1}.zip..." /popup "" "${DownloadDmd1ZipUrl}" "$INSTDIR\dmd.zip" /end
Pop $0 # return value = exit code, "OK" means OK
!else
FILE "/oname=$INSTDIR\dmd.zip" "${DmdZipPath1}"
!endif
; Unzip them right there
nsisunz::Unzip "$INSTDIR\dmd.zip" "$INSTDIR"
; Delete the zip files
Delete "$INSTDIR\dmd.zip"
; Create command line batch file
FileOpen $0 "$INSTDIR\dmd1vars.bat" w
FileWrite $0 "@echo.$\n"
FileWrite $0 "@echo Setting up environment for using DMD 1 from %~dp0dmd\windows\bin.$\n"
FileWrite $0 "@set PATH=%~dp0dmd\windows\bin;%PATH%$\n"
FileClose $0
SectionEnd
Section /o "Add to PATH" AddD1ToPath
; Add dmd 1 directories to path (for all users)
SectionGetFlags ${Dmd1Files} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} +1 +2
${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\dmd\windows\bin"
SectionEnd
SectionGroupEnd
SectionGroup "dmc"
Section "-dmc" DmcFiles
; This section is mandatory
;SectionIn RO
SetOutPath $INSTDIR
; Create installation directory
CreateDirectory "$INSTDIR"
!ifdef Download
; Download the zip files
inetc::get /caption "Downloading dm${VersionDMC}c.zip..." /popup "" "${DownloadDmcZipUrl}" "$INSTDIR\dmc.zip" /end
Pop $0 # return value = exit code, "OK" means OK
!else
FILE "/oname=$INSTDIR\dmc.zip" "${DmcZipPath}"
!endif
; Unzip them right there
nsisunz::Unzip "$INSTDIR\dmc.zip" "$INSTDIR"
; Delete the zip files
Delete "$INSTDIR\dmc.zip"
; Create command line batch file
FileOpen $0 "$INSTDIR\dmcvars.bat" w
FileWrite $0 "@echo.$\n"
FileWrite $0 "@echo Setting up environment for using dmc from %~dp0dm\bin.$\n"
FileWrite $0 "@set PATH=%~dp0dm\bin;%PATH%$\n"
FileClose $0
SectionEnd
Section "Add to PATH" AddDmcToPath
; Add dmc directories to path (for all users)
SectionGetFlags ${DmcFiles} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} +1 +2
${EnvVarUpdate} $0 "PATH" "A" "HKLM" "$INSTDIR\dm\bin"
SectionEnd
SectionGroupEnd
Section "Start Menu Shortcuts" StartMenuShortcuts
CreateDirectory "$SMPROGRAMS\D"
; install dmd 2 documentation and command prompt
SectionGetFlags ${Dmd2Files} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} +1 +4
CreateShortCut "$SMPROGRAMS\D\D2 HTML Documentation.lnk" "$INSTDIR\dmd2\html\d\index.html"
CreateShortCut "$SMPROGRAMS\D\D2 Documentation.lnk" "$INSTDIR\dmd2\windows\bin\d.chm"
CreateShortCut "$SMPROGRAMS\D\D2 32-bit Command Prompt.lnk" '%comspec%' '/k ""$INSTDIR\dmd2vars32.bat""' "" "" SW_SHOWNORMAL "" "Open D2 32-bit Command Prompt"
CreateShortCut "$SMPROGRAMS\D\D2 64-bit Command Prompt.lnk" '%comspec%' '/k ""$INSTDIR\dmd2vars64.bat""' "" "" SW_SHOWNORMAL "" "Open D2 64-bit Command Prompt"
; install dmd 1 documentation and command prompt
SectionGetFlags ${Dmd1Files} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} +1 +3
CreateShortCut "$SMPROGRAMS\D\D1 HTML Documentation.lnk" "$INSTDIR\dmd\html\d\index.html"
CreateShortCut "$SMPROGRAMS\D\D1 Command Prompt.lnk" '%comspec%' '/k ""$INSTDIR\dmd1vars.bat""' "" "" SW_SHOWNORMAL "" "Open D1 Command Prompt"
; install dmc command prompt
SectionGetFlags ${DmcFiles} $0
IntOp $0 $0 & ${SF_SELECTED}
IntCmp $0 ${SF_SELECTED} +1 +2
CreateShortCut "$SMPROGRAMS\D\dmc Command Prompt.lnk" '%comspec%' '/k ""$INSTDIR\dmcvars.bat""' "" "" SW_SHOWNORMAL "" "Open dmc Command Prompt"
CreateShortCut "$SMPROGRAMS\D\$(SHORTCUT_Uninstall).lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
SectionEnd
Section "Visual D" VisualD
SetOutPath $INSTDIR
!ifdef Download
; Download the zip files
inetc::get /caption "Downloading VisualD-v${VersionVisualD}.exe..." /popup "" "${DownloadVisualDUrl}" "$INSTDIR\${VisualDPath}" /end
Pop $0 # return value = exit code, "OK" means OK
!else
FILE "/oname=$INSTDIR\${VisualDPath}" "${VisualDPath}"
!endif
DetailPrint "Running Visual D installer"
ExecWait "$INSTDIR\${VisualDPath}"
Delete "$INSTDIR\${VisualDPath}"
SectionEnd
;--------------------------------------------------------
; Installer functions
;--------------------------------------------------------
Function .onInit
; This is commented because there's only one language
; (for now)
;!insertmacro MUI_LANGDLL_DISPLAY
; Check if a dmd installer instance is already running
!insertmacro OneInstanceOnly
; Force install without uninstall (useful if uninstall is broken)
${GetParameters} $R0
StrCmp $R0 "/f" done
; Remove previous dmd installation if any
; this section is for previous dmd installer only
ReadRegStr $R5 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\D" "UninstallString"
ReadRegStr $R6 HKLM "SOFTWARE\D" "Install_Dir"
StrCmp $R5 "" done2
MessageBox MB_OKCANCEL|MB_ICONQUESTION \
"A previous DMD is installed on your system$\n$\nPress 'OK' to replace by ${DName} ${Version2}" \
IDOK +2
Abort
ClearErrors
; Run uninstaller fron installed directory
ExecWait '$R5 /S _?=$R6' $K
; Exit if uninstaller return an error
IfErrors 0 +3
MessageBox MB_OK|MB_ICONSTOP \
"An error occurred when removing DMD$\n$\nRun '${InstallerFilename} /f' to force install ${DName} ${Version2}"
Abort
; Remove in background the remaining uninstaller program itself
Sleep 1000
Exec '$R5 /S'
; MessageBox MB_OK|MB_ICONINFORMATION "Previous DMD uninstalled"
done2:
; End of removing previous dmd installation section
; Remove if dmd is already installed
ReadRegStr $R0 HKLM "${ARP}" "UninstallString"
StrCmp $R0 "" done
ReadRegStr $I HKLM "${ARP}" "DisplayName"
ReadRegStr $J HKLM "${ARP}" "DisplayVersion"
MessageBox MB_OKCANCEL|MB_ICONQUESTION \
"$I v$J is installed on your system$\n$\nPress 'OK' to replace by ${DName} ${Version2}" \
IDOK uninst
Abort
uninst:
ClearErrors
; Run uninstaller from installed directory
ExecWait '$R0 /IC False _?=$INSTDIR' $K
; Exit if uninstaller return an error
IfErrors 0 +3
MessageBox MB_OK|MB_ICONSTOP \
"An error occurred when removing $I v$J$\n$\nRun '${InstallerFilename} /f' to force install ${DName} ${Version2}"
Abort
; Exit if uninstaller is cancelled by user
StrCmp $K 0 +2
Abort
; Remove in background the remaining uninstaller program itself
Exec '$R0 /IC False /S'
done:
FunctionEnd
; Contains descriptions of components and other stuff
!include dinstaller_descriptions.nsh
;--------------------------------------------------------
; Uninstaller
;--------------------------------------------------------
Section "Uninstall"
; Remove directories to path (for all users)
; (if for the current user, use HKCU)
${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\dm\bin"
${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\dmd\windows\bin"
${un.EnvVarUpdate} $0 "PATH" "R" "HKLM" "$INSTDIR\dmd2\windows\bin"
; Remove stuff from registry
DeleteRegKey HKLM "${ARP}"
DeleteRegKey HKLM "SOFTWARE\${DName}"
; This is for deleting the remembered language of the installation
;DeleteRegKey HKCU Software\D
;DeleteRegKey /ifempty HKCU Software\D
; Remove the uninstaller
Delete $INSTDIR\uninstall.exe
Delete $INSTDIR\dmcvars.bat
Delete $INSTDIR\dmd1vars.bat
Delete $INSTDIR\dmd2vars.bat
Delete $INSTDIR\dmd2vars32.bat
Delete $INSTDIR\dmd2vars64.bat
Delete $INSTDIR\README.txt
; Remove shortcuts
Delete "$SMPROGRAMS\D\D1 HTML Documentation.lnk"
Delete "$SMPROGRAMS\D\D2 HTML Documentation.lnk"
Delete "$SMPROGRAMS\D\D2 Documentation.lnk"
Delete "$SMPROGRAMS\D\$(SHORTCUT_Uninstall).lnk"
RMDir /r /REBOOTOK "$SMPROGRAMS\D"
; Remove used directories
RMDir /r /REBOOTOK "$INSTDIR\dm"
RMDir /r /REBOOTOK "$INSTDIR\dmd"
RMDir /r /REBOOTOK "$INSTDIR\dmd2"
RMDir /REBOOTOK "$INSTDIR"
SectionEnd
;--------------------------------------------------------
; Uninstaller functions
;--------------------------------------------------------
Function un.onInit
; Ask language before starting the uninstall
; This is commented because there's only one language
; (for now)
;!insertmacro MUI_UNGETLANGUAGE
; Check if a dmd installer instance is already running
; Do not check if "/IC False" argument is passed to uninstaller
${GetOptions} $CMDLINE "/IC" $InstanceCheck
${IfNot} "$InstanceCheck" == "False"
!insertmacro OneInstanceOnly
${EndIf}
FunctionEnd