VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Installer/VBoxGuestAdditions.nsi@ 35036

最後變更 在這個檔案從35036是 34745,由 vboxsync 提交於 14 年 前

Windows Guest Additions installer: Back out reboot flag handling (r68547, r68538, r68537, r68536, r68534), needs more testing after beta.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 38.7 KB
 
1
2!if $%BUILD_TYPE% == "debug"
3 !define _DEBUG ; Turn this on to get extra output
4!endif
5
6; Defines for special functions
7!define WHQL_FAKE ; Turns on the faking of non WHQL signed / approved drivers
8 ; Needs the VBoxWHQLFake.exe in the additions output directory!
9
10!define VENDOR_ROOT_KEY "SOFTWARE\$%VBOX_VENDOR_SHORT%"
11
12!define PRODUCT_NAME "$%VBOX_PRODUCT% Guest Additions"
13!define PRODUCT_DESC "$%VBOX_PRODUCT% Guest Additions"
14!define PRODUCT_VERSION "$%VBOX_VERSION_MAJOR%.$%VBOX_VERSION_MINOR%.$%VBOX_VERSION_BUILD%.0"
15!define PRODUCT_PUBLISHER "$%VBOX_VENDOR%"
16!define PRODUCT_COPYRIGHT "(C) $%VBOX_C_YEAR% $%VBOX_VENDOR%"
17!define PRODUCT_OUTPUT "VBoxWindowsAdditions-$%BUILD_TARGET_ARCH%.exe"
18!define PRODUCT_WEB_SITE "http://www.alldomusa.eu.org"
19!define PRODUCT_INSTALL_KEY "${VENDOR_ROOT_KEY}\VirtualBox Guest Additions"
20!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
21!define PRODUCT_UNINST_ROOT_KEY "HKLM"
22
23!define LICENSE_FILE_RTF "license.rtf"
24
25; Needed for InstallLib macro: Install libraries in every case
26!define LIBRARY_IGNORE_VERSION
27
28VIProductVersion "${PRODUCT_VERSION}"
29VIAddVersionKey "FileVersion" "$%VBOX_VERSION_STRING%"
30VIAddVersionKey "ProductName" "${PRODUCT_NAME}"
31VIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}"
32VIAddVersionKey "CompanyName" "${PRODUCT_PUBLISHER}"
33VIAddVersionKey "FileDescription" "${PRODUCT_DESC}"
34VIAddVersionKey "LegalCopyright" "${PRODUCT_COPYRIGHT}"
35VIAddVersionKey "InternalName" "${PRODUCT_OUTPUT}"
36
37; This registry key will hold the mouse driver path before install (NT4 only)
38!define ORG_MOUSE_PATH "MousePath"
39
40; If we have our guest install helper DLL, add the
41; plugin path so that NSIS can find it when compiling the installer
42; Note: NSIS plugins *always* have to be compiled in 32-bit!
43!if $%VBOX_WITH_GUEST_INSTALL_HELPER% == "1"
44 !addplugindir "$%PATH_TARGET_X86%\VBoxGuestInstallHelper"
45!endif
46
47!include "LogicLib.nsh"
48!include "FileFunc.nsh"
49 !insertmacro GetParameters
50 !insertmacro GetOptions
51!include "WordFunc.nsh"
52 !insertmacro WordFind
53 !insertmacro StrFilter
54
55!include "nsProcess.nsh"
56!include "Library.nsh"
57!include "strstr.nsh" ; Function "strstr"
58!include "servicepack.nsh" ; Function "GetServicePack"
59!include "winver.nsh" ; Function for determining Windows version
60!define REPLACEDLL_NOREGISTER ; Replace in use DLL function
61!include "ReplaceDLL.nsh"
62!include "dumplog.nsh" ; Dump log to file function
63
64!if $%BUILD_TARGET_ARCH% == "amd64"
65 !include "x64.nsh"
66!endif
67
68; Set Modern UI (MUI) as default
69!define USE_MUI
70
71!ifdef USE_MUI
72 ; Use modern UI, version 2
73 !include "MUI2.nsh"
74
75 ; MUI Settings
76 !define MUI_WELCOMEFINISHPAGE_BITMAP "$%VBOX_BRAND_WIN_ADD_INST_DLGBMP%"
77 !define MUI_ABORTWARNING
78 !define MUI_WELCOMEPAGE_TITLE_3LINES "Welcome to the ${PRODUCT_NAME} Additions Setup"
79
80 ; API defines
81 !define SM_CLEANBOOT 67
82
83 ; Icons
84 !if $%BUILD_TARGET_ARCH% == "x86" ; 32-bit
85 !define MUI_ICON "$%VBOX_NSIS_ICON_FILE%"
86 !define MUI_UNICON "$%VBOX_NSIS_ICON_FILE%"
87 !else ; 64-bit
88 !define MUI_ICON "$%VBOX_WINDOWS_ADDITIONS_ICON_FILE%"
89 !define MUI_UNICON "$%VBOX_WINDOWS_ADDITIONS_ICON_FILE%"
90 !endif
91
92 ; Welcome page
93 !insertmacro MUI_PAGE_WELCOME
94!ifdef VBOX_WITH_LICENSE_DISPLAY
95 ; License page
96 !insertmacro MUI_PAGE_LICENSE "$(VBOX_LICENSE)"
97 !define MUI_LICENSEPAGE_RADIOBUTTONS
98!endif
99 ; Directory page
100 !insertmacro MUI_PAGE_DIRECTORY
101 ; Components Page
102 !insertmacro MUI_PAGE_COMPONENTS
103 ; Instfiles page
104 !insertmacro MUI_PAGE_INSTFILES
105
106 !ifndef _DEBUG
107 !define MUI_FINISHPAGE_TITLE_3LINES ; Have a bit more vertical space for text
108 !insertmacro MUI_PAGE_FINISH ; Only show in release mode - useful information for debugging!
109 !endif
110
111 ; Uninstaller pages
112 !insertmacro MUI_UNPAGE_INSTFILES
113
114 ; Define languages we will use
115 !insertmacro MUI_LANGUAGE "English"
116 !insertmacro MUI_LANGUAGE "French"
117 !insertmacro MUI_LANGUAGE "German"
118
119 ; Set branding text which appears on the horizontal line at the bottom
120!ifdef _DEBUG
121 BrandingText "VirtualBox Windows Additions $%VBOX_VERSION_STRING% (r$%VBOX_SVN_REV%) - Debug Build"
122!else
123 BrandingText "VirtualBox Windows Additions $%VBOX_VERSION_STRING%"
124!endif
125
126!ifdef VBOX_WITH_LICENSE_DISPLAY
127 ; Set license language
128 LicenseLangString VBOX_LICENSE ${LANG_ENGLISH} "$%VBOX_BRAND_LICENSE_RTF%"
129
130 ; If license files not available (OSE / PUEL) build, then use the English one as default
131 !ifdef VBOX_BRAND_fr_FR_LICENSE_RTF
132 LicenseLangString VBOX_LICENSE ${LANG_FRENCH} "$%VBOX_BRAND_fr_FR_LICENSE_RTF%"
133 !else
134 LicenseLangString VBOX_LICENSE ${LANG_FRENCH} "$%VBOX_BRAND_LICENSE_RTF%"
135 !endif
136 !ifdef VBOX_BRAND_de_DE_LICENSE_RTF
137 LicenseLangString VBOX_LICENSE ${LANG_GERMAN} "$%VBOX_BRAND_de_DE_LICENSE_RTF%"
138 !else
139 LicenseLangString VBOX_LICENSE ${LANG_GERMAN} "$%VBOX_BRAND_LICENSE_RTF%"
140 !endif
141!endif
142
143 !insertmacro MUI_RESERVEFILE_LANGDLL
144!else ; !USE_MUI
145 XPStyle on
146!ifdef VBOX_WITH_LICENSE_DISPLAY
147 Page license
148!endif
149 Page components
150 Page directory
151 Page instfiles
152!endif
153
154; Language files
155!include "Languages\English.nsh"
156!include "Languages\French.nsh"
157!include "Languages\German.nsh"
158
159; Variables and output files
160Name "${PRODUCT_NAME} $%VBOX_VERSION_STRING%"
161!ifdef UNINSTALLER_ONLY
162 !echo "Uninstaller only!"
163 OutFile "$%PATH_TARGET%\VBoxWindowsAdditions-$%BUILD_TARGET_ARCH%-uninst.exe"
164!else
165 OutFile "VBoxWindowsAdditions-$%BUILD_TARGET_ARCH%.exe"
166!endif ; UNINSTALLER_ONLY
167
168; Define default installation directory
169!if $%BUILD_TARGET_ARCH% == "x86" ; 32-bit
170 InstallDir "$PROGRAMFILES32\$%VBOX_VENDOR_SHORT%\VirtualBox Guest Additions"
171!else ; 64-bit
172 InstallDir "$PROGRAMFILES64\$%VBOX_VENDOR_SHORT%\VirtualBox Guest Additions"
173!endif
174
175InstallDirRegKey HKLM "${PRODUCT_DIR_REGKEY}" ""
176ShowInstDetails show
177ShowUnInstDetails show
178RequestExecutionLevel highest
179
180; Internal parameters
181Var g_iSystemMode ; Current system mode (0 = Normal boot, 1 = Fail-safe boot, 2 = Fail-safe with network boot)
182Var g_strSystemDir ; Windows system directory
183Var g_strCurUser ; Current user using the system
184Var g_strAddVerMaj ; Installed Guest Additions: Major version
185Var g_strAddVerMin ; Installed Guest Additions: Minor version
186Var g_strAddVerBuild ; Installed Guest Additions: Build number
187Var g_strAddVerRev ; Installed Guest Additions: SVN revision
188Var g_strWinVersion ; Current Windows version we're running on
189Var g_bLogEnable ; Do logging when installing? "true" or "false"
190Var g_bWithWDDM ; Install the WDDM driver instead of the normal one
191Var g_bCapWDDM ; Capability: Is the guest able to handle/use our WDDM driver?
192
193; Command line parameters - these can be set/modified
194; on the command line
195Var g_bFakeWHQL ; Cmd line: Fake Windows to install non WHQL certificated drivers (only for W2K and XP currently!!) ("/unsig_drv")
196Var g_bForceInstall ; Cmd line: Force installation on unknown Windows OS version
197Var g_bUninstall ; Cmd line: Just uninstall any previous Guest Additions and exit
198Var g_bRebootOnExit ; Cmd line: Auto-Reboot on successful installation. Good for unattended installations ("/reboot")
199Var g_iScreenBpp ; Cmd line: Screen depth ("/depth=X")
200Var g_iScreenX ; Cmd line: Screen resolution X ("/resx=X")
201Var g_iScreenY ; Cmd line: Screen resolution Y ("/resy=Y")
202Var g_iSfOrder ; Cmd line: Order of Shared Folders network provider (0=first, 1=second, ...)
203Var g_bIgnoreUnknownOpts ; Cmd line: Ignore unknown options (don't display the help)
204Var g_bNoVBoxServiceExit ; Cmd line: Do not quit VBoxService before updating - install on next reboot
205Var g_bNoVBoxTrayExit ; Cmd line: Do not quit VBoxTray before updating - install on next reboot
206Var g_bNoVideoDrv ; Cmd line: Do not install the VBoxVideo driver
207Var g_bNoGuestDrv ; Cmd line: Do not install the VBoxGuest driver
208Var g_bNoMouseDrv ; Cmd line: Do not install the VBoxMouse driver
209Var g_bWithAutoLogon ; Cmd line: Install VBoxGINA / VBoxCredProv for auto logon support
210Var g_bWithD3D ; Cmd line: Install Direct3D support
211Var g_bOnlyExtract ; Cmd line: Only extract all files, do *not* install them. Only valid with param "/D" (target directory)
212Var g_bPostInstallStatus ; Cmd line: Post the overall installation status to some external program (VBoxTray)
213
214; Platform parts of this installer
215!include "VBoxGuestAdditionsCommon.nsh"
216!if $%BUILD_TARGET_ARCH% == "x86" ; 32-bit only
217!include "VBoxGuestAdditionsNT4.nsh"
218!endif
219!include "VBoxGuestAdditionsW2KXP.nsh"
220!include "VBoxGuestAdditionsVista.nsh"
221!include "VBoxGuestAdditionsUninstall.nsh" ; Product uninstallation
222!include "VBoxGuestAdditionsUninstallOld.nsh" ; Uninstallation of deprecated versions which must be removed first
223
224Function HandleCommandLine
225
226 Push $0 ; Command line (without process name)
227 Push $1 ; Number of parameters
228 Push $2 ; Current parameter index
229 Push $3 ; Current parameter pair (name=value)
230 Push $4 ; Current parameter name
231 Push $5 ; Current parameter value (if present)
232
233 StrCpy $1 "0" ; Init param counter
234 StrCpy $2 "1" ; Init current param counter
235
236 ${GetParameters} $0 ; Extract command line
237 ${If} $0 == "" ; If no parameters at all exit
238 Goto exit
239 ${EndIf}
240
241 ; Enable for debugging
242 ;MessageBox MB_OK "CmdLine: $0"
243
244 ${WordFind} $0 " " "#" $1 ; Get number of parameters in cmd line
245 ${If} $0 == $1 ; If result matches the input then
246 StrCpy $1 "1" ; no delimiter was found. Correct to 1 word total
247 ${EndIf}
248
249 ${While} $2 <= $1 ; Loop through all params
250
251 ${WordFind} $0 " " "+$2" $3 ; Get current name=value pair
252 ${WordFind} $3 "=" "+1" $4 ; Get current param name
253 ${WordFind} $3 "=" "+2" $5 ; Get current param value
254
255 ${StrFilter} $4 "-" "" "" $4 ; Transfer param name to lowercase
256
257 ; Enable for debugging
258 ;MessageBox MB_OK "#$2 of #$1, param='$3', name=$4, val=$5"
259
260 ${Switch} $4
261
262 ${Case} '/d' ; NSIS: /D=<instdir> switch, skip
263 ${Break}
264
265 ${Case} '/depth'
266 ${Case} 'depth'
267 StrCpy $g_iScreenBpp $5
268 ${Break}
269
270 ${Case} '/extract'
271 StrCpy $g_bOnlyExtract "true"
272 ${Break}
273
274 ${Case} '/force'
275 StrCpy $g_bForceInstall "true"
276 ${Break}
277
278 ${Case} '/help'
279 ${Case} '/H'
280 ${Case} '/h'
281 ${Case} '/?'
282 Goto usage
283 ${Break}
284
285 ${Case} '/ignore_unknownopts' ; Not officially documented
286 StrCpy $g_bIgnoreUnknownOpts "true"
287 ${Break}
288
289 ${Case} '/l'
290 ${Case} '/log'
291 ${Case} '/logging'
292 StrCpy $g_bLogEnable "true"
293 ${Break}
294
295 ${Case} '/ncrc' ; NSIS: /NCRC switch, skip
296 ${Break}
297
298 ${Case} '/no_vboxservice_exit' ; Not officially documented
299 StrCpy $g_bNoVBoxServiceExit "true"
300 ${Break}
301
302 ${Case} '/no_vboxtray_exit' ; Not officially documented
303 StrCpy $g_bNoVBoxTrayExit "true"
304 ${Break}
305
306 ${Case} '/no_videodrv' ; Not officially documented
307 StrCpy $g_bNoVideoDrv "true"
308 ${Break}
309
310 ${Case} '/no_guestdrv' ; Not officially documented
311 StrCpy $g_bNoGuestDrv "true"
312 ${Break}
313
314 ${Case} '/no_mousedrv' ; Not officially documented
315 StrCpy $g_bNoMouseDrv "true"
316 ${Break}
317
318!if $%VBOX_WITH_GUEST_INSTALL_HELPER% == "1"
319 ; This switch tells our installer that it
320 ; - should not quit VBoxTray during the update, because ...
321 ; - ... it should show the overall installation status
322 ; using VBoxTray's balloon message feature (since VBox 4.0)
323 ${Case} '/post_installstatus' ; Not officially documented
324 StrCpy $g_bNoVBoxTrayExit "true"
325 StrCpy $g_bPostInstallStatus "true"
326 ${Break}
327!endif
328
329 ${Case} '/reboot'
330 StrCpy $g_bRebootOnExit "true"
331 ${Break}
332
333 ${Case} '/s' ; NSIS: /S switch, skip
334 ${Break}
335
336 ${Case} '/sforder'
337 ${Case} 'sforder'
338 StrCpy $g_iSfOrder $5
339 ${Break}
340
341 !ifdef WHQL_FAKE
342 ${Case} '/unsig_drv'
343 StrCpy $g_bFakeWHQL "true"
344 ${Break}
345 !endif
346
347 ${Case} '/uninstall'
348 StrCpy $g_bUninstall "true"
349 ${Break}
350
351 ${Case} '/with_autologon'
352 StrCpy $g_bWithAutoLogon "true"
353 ${Break}
354
355 !if $%VBOX_WITH_CROGL% == "1"
356 ${Case} '/with_d3d'
357 ${Case} '/with_direct3d'
358 StrCpy $g_bWithD3D "true"
359 ${Break}
360 !endif
361
362 ${Case} '/xres'
363 ${Case} 'xres'
364 StrCpy $g_iScreenX $5
365 ${Break}
366
367 ${Case} '/yres'
368 ${Case} 'yres'
369 StrCpy $g_iScreenY $5
370 ${Break}
371
372 ${Default} ; Unknown parameter, print usage message
373 ; Prevent popping up usage message on (yet) unknown parameters
374 ; in silent mode, just skip
375 IfSilent 0 +2
376 ${Break}
377 goto usage
378 ${Break}
379
380 ${EndSwitch}
381
382next_param:
383
384 IntOp $2 $2 + 1
385
386 ${EndWhile}
387 Goto exit
388
389usage:
390
391 ; If we were told to ignore unknown (invalid) options, just return to
392 ; the parsing loop ...
393 ${If} $g_bIgnoreUnknownOpts == "true"
394 Goto next_param
395 ${EndIf}
396 MessageBox MB_OK "${PRODUCT_NAME} Installer$\r$\n$\r$\n \
397 Usage: VBoxWindowsAdditions-$%BUILD_TARGET_ARCH% [OPTIONS] [/l] [/S] [/D=<PATH>]$\r$\n$\r$\n \
398 Options:$\r$\n \
399 /depth=BPP$\tSets the guest's display color depth (bits per pixel)$\r$\n \
400 /extract$\t$\tOnly extract installation files$\r$\n \
401 /force$\t$\tForce installation on unknown/undetected Windows versions$\r$\n \
402 /uninstall$\t$\tJust uninstalls the Guest Additions and exits$\r$\n \
403 /with_autologon$\tInstalls auto-logon support$\r$\n \
404 /with_d3d$\tInstalls D3D support$\r$\n \
405 /xres=X$\t$\tSets the guest's display resolution (width in pixels)$\r$\n \
406 /yres=Y$\t$\tSets the guest's display resolution (height in pixels)$\r$\n \
407 $\r$\n \
408 Installer parameters:$\r$\n \
409 /l$\t$\tEnables logging$\r$\n \
410 /S$\t$\tSilent install$\r$\n \
411 /D=<PATH>$\tSets the default install path$\r$\n \
412 $\r$\n \
413 Note: Order of options and installer parameters are mandatory." /SD IDOK
414
415 ; No stack restore needed, we're about to quit
416 Quit
417
418done:
419
420 IfSilent 0 +2
421 LogText "Installer is in silent mode!"
422
423 LogText "Property: XRes: $g_iScreenX"
424 LogText "Property: YRes: $g_iScreenY"
425 LogText "Property: BPP: $g_iScreenBpp"
426 LogText "Property: Logging enabled: $g_bLogEnable"
427
428exit:
429
430 Pop $5
431 Pop $4
432 Pop $3
433 Pop $2
434 Pop $1
435 Pop $0
436
437FunctionEnd
438
439Function CheckForOldGuestAdditions
440
441 Push $0
442 Push $1
443 Push $2
444
445begin:
446
447sun_check:
448
449 ; Check for old "Sun VirtualBox Guest Additions"
450 ; - before rebranding to Oracle
451 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Sun VirtualBox Guest Additions" "UninstallString"
452 StrCmp $0 "" sun_xvm_check ; If string is empty, Sun additions are probably not installed (anymore)
453
454 MessageBox MB_YESNO $(VBOX_SUN_FOUND) /SD IDYES IDYES sun_uninstall
455 Pop $2
456 Pop $1
457 Pop $0
458 MessageBox MB_ICONSTOP $(VBOX_SUN_ABORTED) /SD IDOK
459 Quit
460
461sun_uninstall:
462
463 Call Uninstall_Sun
464 Goto success
465
466sun_xvm_check:
467
468 ; Check for old "Sun xVM VirtualBox Guest Additions"
469 ; - before getting rid of the "xVM" namespace
470 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Sun xVM VirtualBox Guest Additions" "UninstallString"
471 StrCmp $0 "" innotek_check ; If string is empty, Sun xVM additions are probably not installed (anymore)
472
473 MessageBox MB_YESNO $(VBOX_SUN_FOUND) /SD IDYES IDYES sun_xvm_uninstall
474 Pop $2
475 Pop $1
476 Pop $0
477 MessageBox MB_ICONSTOP $(VBOX_SUN_ABORTED) /SD IDOK
478 Quit
479
480sun_xvm_uninstall:
481
482 Call Uninstall_SunXVM
483 Goto success
484
485innotek_check:
486
487 ; Check for old "innotek" Guest Additions" before rebranding to "Sun"
488 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\innotek VirtualBox Guest Additions" "UninstallString"
489 StrCmp $0 "" exit ; If string is empty, innotek Guest Additions are probably not installed (anymore)
490
491 MessageBox MB_YESNO $(VBOX_INNOTEK_FOUND) /SD IDYES IDYES innotek_uninstall
492 Pop $2
493 Pop $1
494 Pop $0
495 MessageBox MB_ICONSTOP $(VBOX_INNOTEK_ABORTED) /SD IDOK
496 Quit
497
498innotek_uninstall:
499
500 Call Uninstall_Innotek
501 Goto success
502
503success:
504
505 ; Nothing to do here yet
506
507exit:
508
509 Pop $2
510 Pop $1
511 Pop $0
512
513FunctionEnd
514
515Function PrepareForUpdate
516
517 StrCmp $g_strAddVerMaj "1" v1 ; Handle major version "v1.x"
518 StrCmp $g_strAddVerMaj "2" v2 ; Handle major version "v2.x"
519 StrCmp $g_strAddVerMaj "3" v3 ; Handle major version "v3.x"
520 Goto exit
521
522v3:
523
524 Goto exit
525
526v2:
527
528 Goto exit
529
530v1:
531
532 StrCmp $g_strAddVerMin "5" v1_5 ; Handle minor version "v1.5.x"
533 StrCmp $g_strAddVerMin "6" v1_6 ; Handle minor version "v1.6.x"
534
535v1_5:
536
537 Goto exit
538
539v1_6:
540
541 Goto exit
542
543exit:
544
545FunctionEnd
546
547Function Common_CopyFiles
548
549 SetOutPath "$INSTDIR"
550 SetOverwrite on
551
552!ifdef VBOX_WITH_LICENSE_INSTALL_RTF
553 ; Copy license file (if any) into the installation directory
554 FILE "/oname=${LICENSE_FILE_RTF}" "$%VBOX_BRAND_LICENSE_RTF%"
555!endif
556
557 FILE "$%PATH_OUT%\bin\additions\VBoxDrvInst.exe"
558
559 FILE "$%PATH_OUT%\bin\additions\VBoxVideo.inf"
560!ifdef VBOX_SIGN_ADDITIONS
561 FILE "$%PATH_OUT%\bin\additions\VBoxVideo.cat"
562!endif
563
564 FILE "iexplore.ico"
565
566FunctionEnd
567
568; Main Files
569Section $(VBOX_COMPONENT_MAIN) SEC01
570
571 SectionIn RO ; Section cannot be unselected (read-only)
572
573 Push "${PRODUCT_NAME} update started, please wait ..."
574 Push 0 ; Message type = info
575 Call WriteLogVBoxTray
576
577 SetOutPath "$INSTDIR"
578 SetOverwrite on
579
580 ; Because this NSIS installer is always built in 32-bit mode, we have to
581 ; do some tricks for the Windows paths
582!if $%BUILD_TARGET_ARCH% == "amd64"
583 ; Because the next two lines will crash at the license page (??) we have to re-enable that here again
584 ${DisableX64FSRedirection}
585 SetRegView 64
586!endif
587
588 StrCpy $g_strSystemDir "$SYSDIR"
589
590 Call EnableLog
591 Call PrepareForUpdate
592
593 DetailPrint "Version: $%VBOX_VERSION_STRING% (Rev $%VBOX_SVN_REV%)"
594 ${If} $g_strAddVerMaj != ""
595 DetailPrint "Previous version: $g_strAddVerMaj.$g_strAddVerMin.$g_strAddVerBuild (Rev $g_strAddVerRev)"
596 ${Else}
597 DetailPrint "No previous version of ${PRODUCT_NAME} detected."
598 ${EndIf}
599 DetailPrint "Detected OS: Windows $g_strWinVersion"
600 DetailPrint "System Directory: $g_strSystemDir"
601
602!ifdef _DEBUG
603 DetailPrint "Debug!"
604!endif
605
606 ; Which OS are we using?
607!if $%BUILD_TARGET_ARCH% == "x86" ; 32-bit
608 StrCmp $g_strWinVersion "NT4" nt4 ; Windows NT 4.0
609!endif
610 StrCmp $g_strWinVersion "2000" w2k ; Windows 2000
611 StrCmp $g_strWinVersion "XP" w2k ; Windows XP
612 StrCmp $g_strWinVersion "2003" w2k ; Windows 2003 Server
613 StrCmp $g_strWinVersion "Vista" vista ; Windows Vista
614 StrCmp $g_strWinVersion "7" vista ; Windows 7
615
616 ${If} $g_bForceInstall == "true"
617 Goto vista ; Assume newer OS than we know of ...
618 ${EndIf}
619
620 Goto notsupported
621
622!if $%BUILD_TARGET_ARCH% == "x86" ; 32-bit
623nt4: ; Windows NT4
624
625 Call GetServicePack
626 Pop $R0 ; Major version
627 Pop $R1 ; Minor version
628
629 ; At least Service Pack 6 installed?
630 ${If} $R0 <> "6"
631 MessageBox MB_YESNO $(VBOX_NT4_NO_SP6) /SD IDYES IDYES +2
632 Quit
633 ${EndIf}
634
635 ; Copy some common files ...
636 Call Common_CopyFiles
637
638 Call NT_Main
639 goto success
640!endif
641
642vista: ; Windows Vista / Windows 7
643
644 ; Copy some common files ...
645 Call Common_CopyFiles
646
647 Call W2K_Main ; First install stuff from Windows 2000 / XP
648 Call Vista_Main ; ... and some specific stuff for Vista / Windows 7
649 goto success
650
651w2k: ; Windows 2000 and XP ...
652
653 ; Copy some common files ...
654 Call Common_CopyFiles
655
656 Call W2K_Main
657 goto success
658
659notsupported:
660
661 MessageBox MB_ICONSTOP $(VBOX_PLATFORM_UNSUPPORTED) /SD IDOK
662 goto exit
663
664success:
665
666 ; Write a registry key with version and installation path for later lookup
667 WriteRegStr HKLM "${PRODUCT_INSTALL_KEY}" "Version" "$%VBOX_VERSION_STRING%"
668 WriteRegStr HKLM "${PRODUCT_INSTALL_KEY}" "Revision" "$%VBOX_SVN_REV%"
669 WriteRegStr HKLM "${PRODUCT_INSTALL_KEY}" "InstallDir" "$INSTDIR"
670
671 ; Set the reboot flag to tell the finish page that is should
672 ; default to the "reboot now" entry
673 SetRebootFlag true
674
675exit:
676
677 Call WriteLogUI
678
679SectionEnd
680
681; Auto-logon support (section is hidden at the moment -- only can be enabled via command line switch)
682Section /o -$(VBOX_COMPONENT_AUTOLOGON) SEC02
683
684 ; Because this NSIS installer is always built in 32-bit mode, we have to
685 ; do some tricks for the Windows paths
686!if $%BUILD_TARGET_ARCH% == "amd64"
687 ; Because the next two lines will crash at the license page (??) we have to re-enable that here again
688 ${DisableX64FSRedirection}
689 SetRegView 64
690!endif
691
692 Call GetWindowsVersion
693 Pop $R0 ; Windows Version
694
695 DetailPrint "Installing auto-logon support ..."
696
697 ; Another GINA already is installed? Check if this is ours, otherwise let the user decide (unless it's a silent setup)
698 ; whether to replace it with the VirtualBox one or not
699 ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" "GinaDLL"
700 ${If} $0 != ""
701 ${If} $0 != "VBoxGINA.dll"
702 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON1 $(VBOX_COMPONENT_AUTOLOGON_WARN_3RDPARTY) /SD IDYES IDYES install
703 goto exit
704 ${EndIf}
705 ${EndIf}
706
707install:
708
709 ; Do we need VBoxCredProv or VBoxGINA?
710 ${If} $R0 == 'Vista'
711 ${OrIf} $R0 == '7'
712 !insertmacro ReplaceDLL "$%PATH_OUT%\bin\additions\VBoxCredProv.dll" "$g_strSystemDir\VBoxCredProv.dll" "$INSTDIR"
713 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\Credential Providers\{275D3BCC-22BB-4948-A7F6-3A3054EBA92B}" "" "VBoxCredProv" ; adding to (default) key
714 WriteRegStr HKCR "CLSID\{275D3BCC-22BB-4948-A7F6-3A3054EBA92B}" "" "VBoxCredProv" ; adding to (Default) key
715 WriteRegStr HKCR "CLSID\{275D3BCC-22BB-4948-A7F6-3A3054EBA92B}\InprocServer32" "" "VBoxCredProv.dll" ; adding to (Default) key
716 WriteRegStr HKCR "CLSID\{275D3BCC-22BB-4948-A7F6-3A3054EBA92B}\InprocServer32" "ThreadingModel" "Apartment"
717 ${Else}
718 !insertmacro ReplaceDLL "$%PATH_OUT%\bin\additions\VBoxGINA.dll" "$g_strSystemDir\VBoxGINA.dll" "$INSTDIR"
719 WriteRegStr HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" "GinaDLL" "VBoxGINA.dll"
720 ${EndIf}
721
722exit:
723
724SectionEnd
725
726; Prepares the access rights for replacing a WRP protected file
727Function PrepareWRPFile
728
729 Pop $0
730 IfFileExists "$g_strSystemDir\takeown.exe" 0 +2
731 nsExec::ExecToLog '"$g_strSystemDir\takeown.exe" /F "$0"'
732 AccessControl::SetFileOwner "$0" "(S-1-5-32-545)"
733 Pop $1
734 DetailPrint "Setting file owner for '$0': $1"
735 AccessControl::GrantOnFile "$0" "(S-1-5-32-545)" "FullAccess"
736 Pop $1
737 DetailPrint "Setting access rights for '$0': $1"
738
739FunctionEnd
740
741; Direct3D support
742!if $%VBOX_WITH_CROGL% == "1"
743Section /o $(VBOX_COMPONENT_D3D) SEC03
744
745!if $%VBOX_WITH_WDDM% == "1"
746 ${If} $g_bWithWDDM == "true"
747 ; All D3D components are installed with WDDM driver package, nothing to be done here
748 Return
749 ${EndIf}
750!endif
751
752 SetOverwrite on
753
754 ${If} $g_strSystemDir == ''
755 StrCpy $g_strSystemDir "$SYSDIR"
756 ${EndIf}
757
758 ; crOpenGL: Do *not* install 64-bit files - they don't work yet (use !define LIBRARY_X64 later)
759 ; Only 32-bit apps on 64-bit work (see next block)
760 !if $%BUILD_TARGET_ARCH% == "x86"
761 SetOutPath $g_strSystemDir
762 DetailPrint "Installing Direct3D support ..."
763 FILE "$%PATH_OUT%\bin\additions\libWine.dll"
764 FILE "$%PATH_OUT%\bin\additions\VBoxD3D8.dll"
765 FILE "$%PATH_OUT%\bin\additions\VBoxD3D9.dll"
766 FILE "$%PATH_OUT%\bin\additions\wined3d.dll"
767
768 ; Update DLL cache
769 SetOutPath "$g_strSystemDir\dllcache"
770 IfFileExists "$g_strSystemDir\dllcache\msd3d8.dll" +1
771 CopyFiles /SILENT "$g_strSystemDir\dllcache\d3d8.dll" "$g_strSystemDir\dllcache\msd3d8.dll"
772 IfFileExists "$g_strSystemDir\dllcache\msd3d9.dll" +1
773 CopyFiles /SILENT "$g_strSystemDir\dllcache\d3d9.dll" "$g_strSystemDir\dllcache\msd3d9.dll"
774
775 Push "$g_strSystemDir\dllcache\d3d8.dll"
776 Call PrepareWRPFile
777
778 Push "$g_strSystemDir\dllcache\d3d9.dll"
779 Call PrepareWRPFile
780
781 ; Exchange DLLs
782 !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%PATH_OUT%\bin\additions\d3d8.dll" "$g_strSystemDir\dllcache\d3d8.dll" "$TEMP"
783 !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%PATH_OUT%\bin\additions\d3d9.dll" "$g_strSystemDir\dllcache\d3d9.dll" "$TEMP"
784
785 ; If exchange above failed, do it on reboot
786 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%PATH_OUT%\bin\additions\d3d8.dll" "$g_strSystemDir\dllcache\d3d8.dll" "$TEMP"
787 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%PATH_OUT%\bin\additions\d3d9.dll" "$g_strSystemDir\dllcache\d3d9.dll" "$TEMP"
788
789 ; Save original DLLs ...
790 SetOutPath $g_strSystemDir
791 IfFileExists "$g_strSystemDir\msd3d8.dll" +1
792 CopyFiles /SILENT "$g_strSystemDir\d3d8.dll" "$g_strSystemDir\msd3d8.dll"
793 IfFileExists "$g_strSystemDir\msd3d8.dll" +1
794 CopyFiles /SILENT "$g_strSystemDir\d3d9.dll" "$g_strSystemDir\msd3d9.dll"
795
796 Push "$g_strSystemDir\d3d8.dll"
797 Call PrepareWRPFile
798
799 Push "$g_strSystemDir\d3d9.dll"
800 Call PrepareWRPFile
801
802 ; Exchange DLLs
803 !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%PATH_OUT%\bin\additions\d3d8.dll" "$g_strSystemDir\d3d8.dll" "$TEMP"
804 !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%PATH_OUT%\bin\additions\d3d9.dll" "$g_strSystemDir\d3d9.dll" "$TEMP"
805
806 ; If exchange above failed, do it on reboot
807 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%PATH_OUT%\bin\additions\d3d8.dll" "$g_strSystemDir\d3d8.dll" "$TEMP"
808 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%PATH_OUT%\bin\additions\d3d9.dll" "$g_strSystemDir\d3d9.dll" "$TEMP"
809 !endif
810
811 !if $%BUILD_TARGET_ARCH% == "amd64"
812 ; Only 64-bit installer: Also copy 32-bit DLLs on 64-bit target arch in
813 ; Wow64 node (32-bit sub system)
814 ${EnableX64FSRedirection}
815 SetOutPath $SYSDIR
816 DetailPrint "Installing Direct3D support (Wow64) ..."
817 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\libWine.dll"
818 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxD3D8.dll"
819 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxD3D9.dll"
820 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\wined3d.dll"
821
822 ; Update DLL cache
823 SetOutPath "$SYSDIR\dllcache"
824 IfFileExists "$SYSDIR\dllcache\msd3d8.dll" +1
825 CopyFiles /SILENT "$SYSDIR\dllcache\d3d8.dll" "$SYSDIR\dllcache\msd3d8.dll"
826 IfFileExists "$SYSDIR\dllcache\msd3d9.dll" +1
827 CopyFiles /SILENT "$SYSDIR\dllcache\d3d9.dll" "$SYSDIR\dllcache\msd3d9.dll"
828
829 Push "$SYSDIR\dllcache\d3d8.dll"
830 Call PrepareWRPFile
831
832 Push "$SYSDIR\dllcache\d3d9.dll"
833 Call PrepareWRPFile
834
835 ; Exchange DLLs
836 !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll" "$SYSDIR\dllcache\d3d8.dll" "$TEMP"
837 !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll" "$SYSDIR\dllcache\d3d9.dll" "$TEMP"
838
839 ; If exchange above failed, do it on reboot
840 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll" "$SYSDIR\dllcache\d3d8.dll" "$TEMP"
841 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll" "$SYSDIR\dllcache\d3d9.dll" "$TEMP"
842
843 ; Save original DLLs ...
844 SetOutPath $SYSDIR
845 IfFileExists "$SYSDIR\dllcache\msd3d8.dll" +1
846 CopyFiles /SILENT "$SYSDIR\d3d8.dll" "$SYSDIR\msd3d8.dll"
847 IfFileExists "$SYSDIR\dllcache\msd3d9.dll" +1
848 CopyFiles /SILENT "$SYSDIR\d3d9.dll" "$SYSDIR\msd3d9.dll"
849
850 Push "$SYSDIR\d3d8.dll"
851 Call PrepareWRPFile
852
853 Push "$SYSDIR\d3d9.dll"
854 Call PrepareWRPFile
855
856 ; Exchange DLLs
857 !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll" "$SYSDIR\d3d8.dll" "$TEMP"
858 !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll" "$SYSDIR\d3d9.dll" "$TEMP"
859
860 ; If exchange above failed, do it on reboot
861 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll" "$SYSDIR\d3d8.dll" "$TEMP"
862 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll" "$SYSDIR\d3d9.dll" "$TEMP"
863
864 ${DisableX64FSRedirection}
865 !endif ; amd64
866 Goto done
867
868error:
869 ; @todo
870 Goto exit
871
872done:
873 MessageBox MB_ICONINFORMATION|MB_OK $(VBOX_WFP_WARN_REPLACE) /SD IDOK
874 Goto exit
875
876exit:
877
878SectionEnd
879!endif ; VBOX_WITH_CROGL
880
881!ifdef USE_MUI
882 ;Assign language strings to sections
883 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
884 !insertmacro MUI_DESCRIPTION_TEXT ${SEC01} $(VBOX_COMPONENT_MAIN_DESC)
885 !insertmacro MUI_DESCRIPTION_TEXT ${SEC02} $(VBOX_COMPONENT_AUTOLOGON_DESC)
886 !if $%VBOX_WITH_CROGL% == "1"
887 !insertmacro MUI_DESCRIPTION_TEXT ${SEC03} $(VBOX_COMPONENT_D3D_DESC)
888 !endif
889 !insertmacro MUI_FUNCTION_DESCRIPTION_END
890!endif ; USE_MUI
891
892Section -Content
893
894 WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
895
896SectionEnd
897
898Section -StartMenu
899
900 CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
901 CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url" "" "$INSTDIR\iexplore.ico"
902 CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk" "$INSTDIR\uninst.exe"
903
904SectionEnd
905
906; This section is called after all the files are in place
907Section -Post
908
909!ifdef _DEBUG
910 DetailPrint "Doing post install ..."
911!endif
912
913!ifdef EXTERNAL_UNINSTALLER
914 SetOutPath "$INSTDIR"
915 FILE "$%PATH_TARGET%\uninst.exe"
916!else
917 WriteUninstaller "$INSTDIR\uninst.exe"
918!endif
919
920 ; Write uninstaller in "Add / Remove programs"
921 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
922 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
923 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
924 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
925 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
926
927 ; Tune TcpWindowSize for a better network throughput
928 WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" "TcpWindowSize" 64240
929
930 DetailPrint "Installation completed."
931
932SectionEnd
933
934; !!! NOTE: This function *has* to be right under the last section; otherwise it does
935; *not* get called! Don't ask me why ... !!!
936Function .onSelChange
937
938 Push $0
939
940 ; Handle selection of D3D component
941 SectionGetFlags ${SEC03} $0
942 ${If} $0 == ${SF_SELECTED}
943
944!if $%VBOX_WITH_WDDM% == "1"
945 ; If we're able to use the WDDM driver just use it instead of the replaced
946 ; D3D components below
947 ${If} $g_bCapWDDM == "true"
948 StrCpy $g_bWithWDDM "true"
949 Goto exit
950 ${EndIf}
951!endif
952
953 ${If} $g_bForceInstall != "true"
954 ; Do not install on < XP
955 ${If} $g_strWinVersion == "NT4"
956 ${OrIf} $g_strWinVersion == "2000"
957 ${OrIf} $g_strWinVersion == ""
958 MessageBox MB_ICONINFORMATION|MB_OK $(VBOX_COMPONENT_D3D_NOT_SUPPORTED) /SD IDOK
959 Goto d3d_disable
960 ${EndIf}
961 ${EndIf}
962
963 ; If we're not in safe mode, print a warning and don't install D3D support
964 ${If} $g_iSystemMode == '0'
965 MessageBox MB_ICONINFORMATION|MB_OK $(VBOX_COMPONENT_D3D_NO_SM) /SD IDOK
966 Goto d3d_disable
967 ${EndIf}
968 ${Else} ; D3D unselected again
969 StrCpy $g_bWithWDDM "false"
970 ${EndIf}
971 Goto exit
972
973d3d_disable:
974
975 IntOp $0 $0 & ${SECTION_OFF} ; Unselect section again
976 SectionSetFlags ${SEC03} $0
977 Goto exit
978
979exit:
980
981 Pop $0
982
983FunctionEnd
984
985; This function is called when a critical error occurred
986Function .onInstFailed
987
988 MessageBox MB_ICONSTOP $(VBOX_ERROR_INST_FAILED) /SD IDOK
989
990 Push "Error while installing ${PRODUCT_NAME}!"
991 Push 2 ; Message type = error
992 Call WriteLogVBoxTray
993
994 StrCpy $g_bLogEnable "true"
995 Call WriteLogUI
996 SetErrorLevel 1
997
998FunctionEnd
999
1000; This function is called when installation was successful!
1001Function .onInstSuccess
1002
1003 Push "${PRODUCT_NAME} successfully updated!"
1004 Push 0 ; Message type = info
1005 Call WriteLogVBoxTray
1006
1007FunctionEnd
1008
1009; This function is called at the very beginning of installer execution
1010Function .onInit
1011
1012 ; Init values
1013 StrCpy $g_iSystemMode "0"
1014 StrCpy $g_strCurUser "<None>"
1015 StrCpy $g_strAddVerMaj "0"
1016 StrCpy $g_strAddVerMin "0"
1017 StrCpy $g_strAddVerBuild "0"
1018 StrCpy $g_strAddVerRev "0"
1019
1020 StrCpy $g_bIgnoreUnknownOpts "false"
1021 StrCpy $g_bLogEnable "false"
1022 StrCpy $g_bFakeWHQL "false"
1023 StrCpy $g_bForceInstall "false"
1024 StrCpy $g_bUninstall "false"
1025 StrCpy $g_bRebootOnExit "false"
1026 StrCpy $g_iScreenX "0"
1027 StrCpy $g_iScreenY "0"
1028 StrCpy $g_iScreenBpp "0"
1029 StrCpy $g_iSfOrder "0"
1030 StrCpy $g_bNoVBoxServiceExit "false"
1031 StrCpy $g_bNoVBoxTrayExit "false"
1032 StrCpy $g_bNoVideoDrv "false"
1033 StrCpy $g_bNoGuestDrv "false"
1034 StrCpy $g_bNoMouseDrv "false"
1035 StrCpy $g_bWithAutoLogon "false"
1036 StrCpy $g_bWithD3D "false"
1037 StrCpy $g_bOnlyExtract "false"
1038 StrCpy $g_bWithWDDM "false"
1039 StrCpy $g_bCapWDDM "false"
1040 StrCpy $g_bPostInstallStatus "false"
1041
1042 SetErrorLevel 0
1043 ClearErrors
1044
1045!ifdef UNINSTALLER_ONLY
1046
1047 ;
1048 ; If UNINSTALLER_ONLY is defined, we're only interested in uninst.exe
1049 ; so we can sign it
1050 ;
1051 ; Note that the Quit causes the exit status to be 2 instead of 0
1052 ;
1053 WriteUninstaller "$%PATH_TARGET%\uninst.exe"
1054 Quit
1055
1056!else
1057
1058 ; Handle command line
1059 Call HandleCommandLine
1060
1061 ; Check if there's already another instance of the installer is running -
1062 ; important for preventing NT4 to spawn the installer twice
1063 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "VBoxGuestInstaller") ?e'
1064 Pop $0
1065 ${If} $0 != 0
1066 Quit
1067 ${EndIf}
1068
1069 ; Retrieve Windows version and store result in $g_strWinVersion
1070 Call GetWindowsVer
1071
1072 ; Retrieve capabilities
1073 Call CheckForCapabilities
1074
1075 ; Get user Name
1076 AccessControl::GetCurrentUserName
1077 Pop $g_strCurUser
1078 DetailPrint "Current user: $g_strCurUser"
1079
1080 ; Only extract files? This action can be called even from non-Admin users
1081 ; and non-compatible architectures
1082 ${If} $g_bOnlyExtract == "true"
1083 Call ExtractFiles
1084 MessageBox MB_OK|MB_ICONINFORMATION $(VBOX_EXTRACTION_COMPLETE) /SD IDOK
1085 Quit
1086 ${EndIf}
1087
1088 ; Check for correct architecture
1089 Call CheckArchitecture
1090 Pop $0
1091 ${If} $0 <> 0 ; Wrong architecture? Tell the world
1092!if $%BUILD_TARGET_ARCH% == "amd64"
1093 MessageBox MB_ICONSTOP $(VBOX_NOTICE_ARCH_AMD64) /SD IDOK
1094!else
1095 MessageBox MB_ICONSTOP $(VBOX_NOTICE_ARCH_X86) /SD IDOK
1096!endif
1097 Abort
1098 ${EndIf}
1099
1100 ; Has the user who calls us admin rights?
1101 UserInfo::GetAccountType
1102 Pop $0
1103 ${If} $0 != "Admin"
1104 MessageBox MB_ICONSTOP $(VBOX_NOADMIN) /SD IDOK
1105 Abort
1106 ${EndIf}
1107
1108 ; Only uninstall?
1109 ${If} $g_bUninstall == "true"
1110 Call Uninstall_Innotek
1111 Call Uninstall
1112 MessageBox MB_ICONINFORMATION|MB_OK $(VBOX_UNINST_SUCCESS) /SD IDOK
1113 Quit
1114 ${EndIf}
1115
1116 ; Set section bits
1117 ${If} $g_bWithAutoLogon == "true" ; Auto-logon support
1118 SectionSetFlags ${SEC02} ${SF_SELECTED}
1119 ${EndIf}
1120!if $%VBOX_WITH_CROGL% == "1"
1121 ${If} $g_bWithD3D == "true" ; D3D support
1122 SectionSetFlags ${SEC03} ${SF_SELECTED}
1123 ${EndIf}
1124!endif
1125
1126!ifdef USE_MUI
1127 ; Display language selection dialog (will be hidden in silent mode!)
1128 !ifdef VBOX_INSTALLER_ADD_LANGUAGES
1129 !insertmacro MUI_LANGDLL_DISPLAY
1130 !endif
1131!endif
1132
1133 ; Because this NSIS installer is always built in 32-bit mode, we have to
1134 ; do some tricks for the Windows paths for checking for old additions
1135 ; in block below
1136!if $%BUILD_TARGET_ARCH% == "amd64"
1137 ${DisableX64FSRedirection}
1138 SetRegView 64
1139!endif
1140
1141 ; Check for old additions
1142 Call CheckForOldGuestAdditions
1143 Call GetAdditionsVersion
1144
1145 ; Due to some bug in NSIS the license page won't be displayed if we're in
1146 ; 64-bit registry view, so as a workaround switch back to 32-bit (Wow6432Node)
1147 ; mode for now
1148!if $%BUILD_TARGET_ARCH% == "amd64"
1149 ${EnableX64FSRedirection}
1150 SetRegView 32
1151!endif
1152
1153!endif ; UNINSTALLER_ONLY
1154
1155FunctionEnd
1156
1157;
1158; The uninstaller is built separately when doing code signing
1159; For some reason NSIS still finds the Uninstall section even
1160; when EXTERNAL_UNINSTALLER is defined. This causes a silly warning
1161;
1162!ifndef EXTERNAL_UNINSTALLER
1163
1164Function un.onUninstSuccess
1165
1166 HideWindow
1167 MessageBox MB_ICONINFORMATION|MB_OK $(VBOX_UNINST_SUCCESS) /SD IDOK
1168
1169FunctionEnd
1170
1171Function un.onInit
1172
1173 ; Has the user who calls us admin rights?
1174 UserInfo::GetAccountType
1175 Pop $0
1176 ${If} $0 != "Admin"
1177 MessageBox MB_ICONSTOP $(VBOX_NOADMIN) /SD IDOK
1178 Abort
1179 ${EndIf}
1180
1181 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 $(VBOX_UNINST_CONFIRM) /SD IDYES IDYES proceed
1182 Quit
1183
1184proceed:
1185
1186 ; Because this NSIS installer is always built in 32-bit mode, we have to
1187 ; do some tricks for the Windows paths
1188!if $%BUILD_TARGET_ARCH% == "amd64"
1189 ${DisableX64FSRedirection}
1190 SetRegView 64
1191!endif
1192
1193 ; Set system directory
1194 StrCpy $g_strSystemDir "$SYSDIR"
1195
1196 ; Retrieve Windows version we're running on and store it in $g_strWinVersion
1197 Call un.GetWindowsVer
1198
1199 ; Retrieve capabilities
1200 Call un.CheckForCapabilities
1201
1202FunctionEnd
1203
1204Section Uninstall
1205
1206!ifdef _DEBUG
1207 ; Enable logging
1208 Call un.EnableLog
1209!endif
1210
1211 ; Because this NSIS installer is always built in 32-bit mode, we have to
1212 ; do some tricks for the Windows paths
1213!if $%BUILD_TARGET_ARCH% == "amd64"
1214 ; Do *not* add this line in .onInit - it will crash at the license page (??) because of a weird NSIS bug
1215 ${DisableX64FSRedirection}
1216 SetRegView 64
1217!endif
1218
1219 ; Call the uninstall main function
1220 Call un.Uninstall
1221
1222 ; ... and remove the local install directory
1223 Call un.UninstallInstDir
1224
1225!ifndef _DEBUG
1226 SetAutoClose true
1227 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 $(VBOX_REBOOT_REQUIRED) /SD IDNO IDYES restart
1228 StrCmp $g_bRebootOnExit "true" restart
1229!endif
1230
1231 Goto exit
1232
1233restart:
1234
1235 DetailPrint "Rebooting ..."
1236 Reboot
1237
1238exit:
1239
1240SectionEnd
1241
1242; !EXTERNAL_UNINSTALLER
1243!endif
1244
1245;Direct the output to our bin dir
1246!cd "$%PATH_OUT%\bin\additions"
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette