VirtualBox

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

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

Windows Guest Additions installer: More D3D verification stuff; more verbose logging about D3D installation.

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