VirtualBox

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

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

Windows Guest Additions installer: Use new VBoxDrvInst command line, add DIFxAPI.dll, clean up, some NT4 renaming.

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

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