VirtualBox

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

Last change on this file since 39561 was 39561, checked in by vboxsync, 13 years ago

Windows Guest Additions installer: Only install D3D DLL cache files if needed, use more LogicLib stuff.

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

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