VirtualBox

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

Last change on this file since 44871 was 44871, checked in by vboxsync, 12 years ago

Windows Guest Additions installer: Implemented auto-updating MMR support.

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