VirtualBox

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

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

Windows Guest Additions installer: Check for invalid/corrupted D3D files.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 40.4 KB
Line 
1; $Id: VBoxGuestAdditions.nsi 39558 2011-12-08 15:02:48Z 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 IfFileExists "$0" +3 +1
729 LogText "WRP: File $0 does not exist, skipping"
730 Return
731
732 IfFileExists "$g_strSystemDir\takeown.exe" +1 +4
733 nsExec::ExecToLog '"$g_strSystemDir\takeown.exe" /F "$0"'
734 Pop $1 ; Ret value
735 LogText "WRP: Taking ownership for $0 returned: $1"
736
737 AccessControl::SetFileOwner "$0" "(S-1-5-32-545)"
738 Pop $1
739 DetailPrint "WRP: Setting file owner for $0 returned: $1"
740
741 AccessControl::GrantOnFile "$0" "(S-1-5-32-545)" "FullAccess"
742 Pop $1
743 DetailPrint "WRP: Setting access rights for $0 returned: $1"
744
745!if $%VBOX_WITH_GUEST_INSTALL_HELPER% == "1"
746 !ifdef WFP_FILE_EXCEPTION
747 VBoxGuestInstallHelper::DisableWFP "$0"
748 Pop $1 ; Get return value (ignored for now)
749 DetailPrint "WRP: Setting WFP exception for $0 returned: $1"
750 !endif
751!endif
752
753FunctionEnd
754
755; Direct3D support
756Section /o $(VBOX_COMPONENT_D3D) SEC03
757
758!if $%VBOX_WITH_WDDM% == "1"
759 ${If} $g_bWithWDDM == "true"
760 ; All D3D components are installed with WDDM driver package, nothing to be done here
761 Return
762 ${EndIf}
763!endif
764
765 SetOverwrite on
766
767 ${If} $g_strSystemDir == ''
768 StrCpy $g_strSystemDir "$SYSDIR"
769 ${EndIf}
770
771 SetOutPath $g_strSystemDir
772 DetailPrint "Installing Direct3D support ..."
773 !if $%BUILD_TARGET_ARCH% == "x86"
774 FILE "$%PATH_OUT%\bin\additions\libWine.dll"
775 !endif
776 FILE "$%PATH_OUT%\bin\additions\VBoxD3D8.dll"
777 FILE "$%PATH_OUT%\bin\additions\VBoxD3D9.dll"
778 FILE "$%PATH_OUT%\bin\additions\wined3d.dll"
779
780 ; Update DLL cache
781 SetOutPath "$g_strSystemDir\dllcache"
782 IfFileExists "$g_strSystemDir\dllcache\msd3d8.dll" +2
783 CopyFiles /SILENT "$g_strSystemDir\dllcache\d3d8.dll" "$g_strSystemDir\dllcache\msd3d8.dll"
784 IfFileExists "$g_strSystemDir\dllcache\msd3d9.dll" +2
785 CopyFiles /SILENT "$g_strSystemDir\dllcache\d3d9.dll" "$g_strSystemDir\dllcache\msd3d9.dll"
786
787 Push "$g_strSystemDir\dllcache\d3d8.dll"
788 Call PrepareWRPFile
789
790 Push "$g_strSystemDir\dllcache\d3d9.dll"
791 Call PrepareWRPFile
792
793 ; Exchange DLLs
794 !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%PATH_OUT%\bin\additions\d3d8.dll" "$g_strSystemDir\dllcache\d3d8.dll" "$TEMP"
795 !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%PATH_OUT%\bin\additions\d3d9.dll" "$g_strSystemDir\dllcache\d3d9.dll" "$TEMP"
796
797 ; If exchange above failed, do it on reboot
798 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%PATH_OUT%\bin\additions\d3d8.dll" "$g_strSystemDir\dllcache\d3d8.dll" "$TEMP"
799 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%PATH_OUT%\bin\additions\d3d9.dll" "$g_strSystemDir\dllcache\d3d9.dll" "$TEMP"
800
801 ; Save original DLLs (only if msd3d*.dll does not exist) ...
802 SetOutPath $g_strSystemDir
803 IfFileExists "$g_strSystemDir\msd3d8.dll" +2
804 CopyFiles /SILENT "$g_strSystemDir\d3d8.dll" "$g_strSystemDir\msd3d8.dll"
805 IfFileExists "$g_strSystemDir\msd3d9.dll" +2
806 CopyFiles /SILENT "$g_strSystemDir\d3d9.dll" "$g_strSystemDir\msd3d9.dll"
807
808 Push "$g_strSystemDir\d3d8.dll"
809 Call PrepareWRPFile
810
811 Push "$g_strSystemDir\d3d9.dll"
812 Call PrepareWRPFile
813
814 ; Exchange DLLs
815 !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%PATH_OUT%\bin\additions\d3d8.dll" "$g_strSystemDir\d3d8.dll" "$TEMP"
816 !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%PATH_OUT%\bin\additions\d3d9.dll" "$g_strSystemDir\d3d9.dll" "$TEMP"
817
818 ; If exchange above failed, do it on reboot
819 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%PATH_OUT%\bin\additions\d3d8.dll" "$g_strSystemDir\d3d8.dll" "$TEMP"
820 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%PATH_OUT%\bin\additions\d3d9.dll" "$g_strSystemDir\d3d9.dll" "$TEMP"
821
822 !if $%BUILD_TARGET_ARCH% == "amd64"
823 ; Only 64-bit installer:
824 ; Also copy 32-bit DLLs on 64-bit Windows in SysWOW64 node
825 SetOutPath $g_strSysWow64
826 DetailPrint "Installing Direct3D support (SysWOW64: $g_strSysWow64) ..."
827 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\libWine.dll"
828 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxD3D8.dll"
829 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxD3D9.dll"
830 FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\wined3d.dll"
831
832 ;
833 ; Update DLL cache
834 ;
835
836 ; Save original DLLs (only if msd3d*.dll does not exist) ...
837 SetOutPath "$g_strSysWow64\dllcache"
838 IfFileExists "$g_strSysWow64\dllcache\msd3d8.dll" +2
839 CopyFiles /SILENT "$g_strSysWow64\dllcache\d3d8.dll" "$g_strSysWow64\dllcache\msd3d8.dll"
840 IfFileExists "$g_strSysWow64\dllcache\msd3d9.dll" +2
841 CopyFiles /SILENT "$g_strSysWow64\dllcache\d3d9.dll" "$g_strSysWow64\dllcache\msd3d9.dll"
842
843 Push "$g_strSysWow64\dllcache\d3d8.dll"
844 Call PrepareWRPFile
845
846 Push "$g_strSysWow64\dllcache\d3d9.dll"
847 Call PrepareWRPFile
848
849 ; Exchange DLLs
850 !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll" "$g_strSysWow64\dllcache\d3d8.dll" "$TEMP"
851 !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll" "$g_strSysWow64\dllcache\d3d9.dll" "$TEMP"
852
853 ; If exchange above failed, do it on reboot
854 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll" "$g_strSysWow64\dllcache\d3d8.dll" "$TEMP"
855 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll" "$g_strSysWow64\dllcache\d3d9.dll" "$TEMP"
856
857 ;
858 ; Update original DLLs
859 ;
860
861 ; Save original DLLs (only if msd3d*.dll does not exist) ...
862 IfFileExists "$g_strSysWow64\msd3d8.dll" +2
863 CopyFiles /SILENT "$g_strSysWow64\d3d8.dll" "$g_strSysWow64\msd3d8.dll"
864 IfFileExists "$g_strSysWow64\msd3d9.dll" +2
865 CopyFiles /SILENT "$g_strSysWow64\d3d9.dll" "$g_strSysWow64\msd3d9.dll"
866
867 Push "$g_strSysWow64\d3d8.dll"
868 Call PrepareWRPFile
869
870 Push "$g_strSysWow64\d3d9.dll"
871 Call PrepareWRPFile
872
873 ; Exchange DLLs
874 !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll" "$g_strSysWow64\d3d8.dll" "$TEMP"
875 !insertmacro InstallLib DLL NOTSHARED NOREBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll" "$g_strSysWow64\d3d9.dll" "$TEMP"
876
877 ; If exchange above failed, do it on reboot
878 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll" "$g_strSysWow64\d3d8.dll" "$TEMP"
879 !insertmacro InstallLib DLL NOTSHARED REBOOT_NOTPROTECTED "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll" "$g_strSysWow64\d3d9.dll" "$TEMP"
880
881 !endif ; amd64
882 Goto done
883
884error:
885 ; @todo
886 Goto exit
887
888done:
889
890!ifndef WFP_FILE_EXCEPTION
891 MessageBox MB_ICONINFORMATION|MB_OK $(VBOX_WFP_WARN_REPLACE) /SD IDOK
892!endif
893 Goto exit
894
895exit:
896
897SectionEnd
898
899!ifdef USE_MUI
900 ;Assign language strings to sections
901 !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
902 !insertmacro MUI_DESCRIPTION_TEXT ${SEC01} $(VBOX_COMPONENT_MAIN_DESC)
903 !insertmacro MUI_DESCRIPTION_TEXT ${SEC02} $(VBOX_COMPONENT_AUTOLOGON_DESC)
904 !if $%VBOX_WITH_CROGL% == "1"
905 !insertmacro MUI_DESCRIPTION_TEXT ${SEC03} $(VBOX_COMPONENT_D3D_DESC)
906 !endif
907 !insertmacro MUI_FUNCTION_DESCRIPTION_END
908!endif ; USE_MUI
909
910Section -Content
911
912 WriteIniStr "$INSTDIR\${PRODUCT_NAME}.url" "InternetShortcut" "URL" "${PRODUCT_WEB_SITE}"
913
914SectionEnd
915
916Section -StartMenu
917
918 CreateDirectory "$SMPROGRAMS\${PRODUCT_NAME}"
919 CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url" "" "$INSTDIR\iexplore.ico"
920 CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Uninstall.lnk" "$INSTDIR\uninst.exe"
921
922SectionEnd
923
924; This section is called after all the files are in place
925Section -Post
926
927!ifdef _DEBUG
928 DetailPrint "Doing post install ..."
929!endif
930
931!ifdef EXTERNAL_UNINSTALLER
932 SetOutPath "$INSTDIR"
933 FILE "$%PATH_TARGET%\uninst.exe"
934!else
935 WriteUninstaller "$INSTDIR\uninst.exe"
936!endif
937
938 ; Write uninstaller in "Add / Remove programs"
939 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayName" "$(^Name)"
940 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
941 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
942 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "URLInfoAbout" "${PRODUCT_WEB_SITE}"
943 WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "Publisher" "${PRODUCT_PUBLISHER}"
944
945 ; Tune TcpWindowSize for a better network throughput
946 WriteRegDWORD HKLM "SYSTEM\CurrentControlSet\Services\Tcpip\Parameters" "TcpWindowSize" 64240
947
948 DetailPrint "Installation completed."
949
950SectionEnd
951
952; !!! NOTE: This function *has* to be right under the last section; otherwise it does
953; *not* get called! Don't ask me why ... !!!
954Function .onSelChange
955
956 Push $0
957
958 ; Handle selection of D3D component
959 SectionGetFlags ${SEC03} $0
960 ${If} $0 == ${SF_SELECTED}
961
962 StrCpy $g_bWithD3D "true"
963
964!if $%VBOX_WITH_WDDM% == "1"
965 ; If we're able to use the WDDM driver just use it instead of the replaced
966 ; D3D components below
967 ${If} $g_bCapWDDM == "true"
968 ;
969 ; Temporary solution: Since WDDM is marked as experimental yet we notify the user
970 ; that WDDM (Aero) support is available but not recommended for production use. He now
971 ; can opt-in for installing WDDM or still go for the old (XPDM) way -- safe mode still required!
972 ;
973 MessageBox MB_ICONQUESTION|MB_YESNO $(VBOX_COMPONENT_D3D_OR_WDDM) /SD IDNO IDYES d3d_install
974 ; Display an uncoditional hint about needed VRAM sizes
975 ; Note: We also could use the PCI configuration space (WMI: Win32_SystemSlot Class) for querying
976 ; the current VRAM size, but let's keep it simple for now
977 MessageBox MB_ICONINFORMATION|MB_OK $(VBOX_COMPONENT_D3D_HINT_VRAM) /SD IDOK
978 StrCpy $g_bWithWDDM "true"
979 Goto exit
980 ${EndIf}
981
982d3d_install:
983
984!endif ; $%VBOX_WITH_WDDM% == "1"
985
986 ${If} $g_bForceInstall != "true"
987 ; Do not install on < XP
988 ${If} $g_strWinVersion == "NT4"
989 ${OrIf} $g_strWinVersion == "2000"
990 ${OrIf} $g_strWinVersion == ""
991 MessageBox MB_ICONINFORMATION|MB_OK $(VBOX_COMPONENT_D3D_NOT_SUPPORTED) /SD IDOK
992 Goto d3d_disable
993 ${EndIf}
994 ${EndIf}
995
996 ; If force flag is set skip the safe mode check
997 ${If} $g_bForceInstall != "true"
998 ; If we're not in safe mode, print a warning and don't install D3D support
999 ${If} $g_iSystemMode == '0'
1000 MessageBox MB_ICONINFORMATION|MB_OK $(VBOX_COMPONENT_D3D_NO_SM) /SD IDOK
1001 Goto d3d_disable
1002 ${EndIf}
1003 ${EndIf}
1004
1005 ${Else} ; D3D unselected again
1006
1007 ${If} $g_strWinVersion != "8" ; On Windows 8 WDDM is mandatory
1008 StrCpy $g_bWithWDDM "false"
1009 ${EndIf}
1010
1011 ${EndIf}
1012 Goto exit
1013
1014d3d_disable:
1015
1016 StrCpy $g_bWithD3D "false"
1017 IntOp $0 $0 & ${SECTION_OFF} ; Unselect section again
1018 SectionSetFlags ${SEC03} $0
1019 Goto exit
1020
1021exit:
1022
1023 Pop $0
1024
1025FunctionEnd
1026
1027; This function is called when a critical error occurred
1028Function .onInstFailed
1029
1030 MessageBox MB_ICONSTOP $(VBOX_ERROR_INST_FAILED) /SD IDOK
1031
1032 Push "Error while installing ${PRODUCT_NAME}!"
1033 Push 2 ; Message type = error
1034 Call WriteLogVBoxTray
1035
1036 StrCpy $g_bLogEnable "true"
1037 Call WriteLogUI
1038 SetErrorLevel 1
1039
1040FunctionEnd
1041
1042; This function is called when installation was successful!
1043Function .onInstSuccess
1044
1045 Push "${PRODUCT_NAME} successfully updated!"
1046 Push 0 ; Message type = info
1047 Call WriteLogVBoxTray
1048
1049FunctionEnd
1050
1051; This function is called at the very beginning of installer execution
1052Function .onInit
1053
1054 Push $0
1055
1056 ; Init values
1057 StrCpy $g_iSystemMode "0"
1058 StrCpy $g_strCurUser "<None>"
1059 StrCpy $g_strAddVerMaj "0"
1060 StrCpy $g_strAddVerMin "0"
1061 StrCpy $g_strAddVerBuild "0"
1062 StrCpy $g_strAddVerRev "0"
1063
1064 StrCpy $g_bIgnoreUnknownOpts "false"
1065 StrCpy $g_bLogEnable "false"
1066 StrCpy $g_bFakeWHQL "false"
1067 StrCpy $g_bForceInstall "false"
1068 StrCpy $g_bUninstall "false"
1069 StrCpy $g_bRebootOnExit "false"
1070 StrCpy $g_iScreenX "0"
1071 StrCpy $g_iScreenY "0"
1072 StrCpy $g_iScreenBpp "0"
1073 StrCpy $g_iSfOrder "0"
1074 StrCpy $g_bNoVBoxServiceExit "false"
1075 StrCpy $g_bNoVBoxTrayExit "false"
1076 StrCpy $g_bNoVideoDrv "false"
1077 StrCpy $g_bNoGuestDrv "false"
1078 StrCpy $g_bNoMouseDrv "false"
1079 StrCpy $g_bWithAutoLogon "false"
1080 StrCpy $g_bWithD3D "false"
1081 StrCpy $g_bOnlyExtract "false"
1082 StrCpy $g_bWithWDDM "false"
1083 StrCpy $g_bCapWDDM "false"
1084 StrCpy $g_bPostInstallStatus "false"
1085
1086 ; We need a special directory set to SysWOW64 because some
1087 ; shell operations don't support file redirection (yet)
1088 StrCpy $g_strSysWow64 "$WINDIR\SysWOW64"
1089
1090 SetErrorLevel 0
1091 ClearErrors
1092
1093!ifdef UNINSTALLER_ONLY
1094
1095 ;
1096 ; If UNINSTALLER_ONLY is defined, we're only interested in uninst.exe
1097 ; so we can sign it
1098 ;
1099 ; Note that the Quit causes the exit status to be 2 instead of 0
1100 ;
1101 WriteUninstaller "$%PATH_TARGET%\uninst.exe"
1102 Quit
1103
1104!else
1105
1106 ; Handle command line
1107 Call HandleCommandLine
1108
1109 ; Check if there's already another instance of the installer is running -
1110 ; important for preventing NT4 to spawn the installer twice
1111 System::Call 'kernel32::CreateMutexA(i 0, i 0, t "VBoxGuestInstaller") ?e'
1112 Pop $0
1113 ${If} $0 != 0
1114 Quit
1115 ${EndIf}
1116
1117 ; Retrieve Windows version and store result in $g_strWinVersion
1118 Call GetWindowsVer
1119
1120 ; Retrieve capabilities
1121 Call CheckForCapabilities
1122
1123 ; Get user Name
1124 AccessControl::GetCurrentUserName
1125 Pop $g_strCurUser
1126 DetailPrint "Current user: $g_strCurUser"
1127
1128 ; Only extract files? This action can be called even from non-Admin users
1129 ; and non-compatible architectures
1130 ${If} $g_bOnlyExtract == "true"
1131 Call ExtractFiles
1132 MessageBox MB_OK|MB_ICONINFORMATION $(VBOX_EXTRACTION_COMPLETE) /SD IDOK
1133 Quit
1134 ${EndIf}
1135
1136 ; Check for correct architecture
1137 Call CheckArchitecture
1138 Pop $0
1139 ${If} $0 <> 0 ; Wrong architecture? Tell the world
1140!if $%BUILD_TARGET_ARCH% == "amd64"
1141 MessageBox MB_ICONSTOP $(VBOX_NOTICE_ARCH_AMD64) /SD IDOK
1142!else
1143 MessageBox MB_ICONSTOP $(VBOX_NOTICE_ARCH_X86) /SD IDOK
1144!endif
1145 Abort
1146 ${EndIf}
1147
1148 ; Has the user who calls us admin rights?
1149 UserInfo::GetAccountType
1150 Pop $0
1151 ${If} $0 != "Admin"
1152 MessageBox MB_ICONSTOP $(VBOX_NOADMIN) /SD IDOK
1153 Abort
1154 ${EndIf}
1155
1156 ; Only uninstall?
1157 ${If} $g_bUninstall == "true"
1158 Call Uninstall_Innotek
1159 Call Uninstall
1160 MessageBox MB_ICONINFORMATION|MB_OK $(VBOX_UNINST_SUCCESS) /SD IDOK
1161 Quit
1162 ${EndIf}
1163
1164 Call CheckForInstalledComponents
1165
1166 ; Set section bits
1167 ${If} $g_bWithAutoLogon == "true" ; Auto-logon support
1168 SectionSetFlags ${SEC02} ${SF_SELECTED}
1169 ${EndIf}
1170!if $%VBOX_WITH_CROGL% == "1"
1171 ${If} $g_bWithD3D == "true" ; D3D support
1172 SectionSetFlags ${SEC03} ${SF_SELECTED}
1173 ${EndIf}
1174!endif
1175 ; On Windows 8 we always select the 3D section and
1176 ; disable it so that it cannot be deselected again
1177 ${If} $g_strWinVersion == "8"
1178 IntOp $0 ${SF_SELECTED} | ${SF_RO}
1179 SectionSetFlags ${SEC03} $0
1180 ${EndIf}
1181
1182!ifdef USE_MUI
1183 ; Display language selection dialog (will be hidden in silent mode!)
1184 !ifdef VBOX_INSTALLER_ADD_LANGUAGES
1185 !insertmacro MUI_LANGDLL_DISPLAY
1186 !endif
1187!endif
1188
1189 Call SetAppMode64
1190
1191 ; Check for old additions
1192 Call CheckForOldGuestAdditions
1193 Call GetAdditionsVersion
1194
1195 ; Due to some bug in NSIS the license page won't be displayed if we're in
1196 ; 64-bit registry view, so as a workaround switch back to 32-bit (Wow6432Node)
1197 ; mode for now
1198 Call SetAppMode32
1199
1200!endif ; UNINSTALLER_ONLY
1201
1202 Pop $0
1203
1204FunctionEnd
1205
1206;
1207; The uninstaller is built separately when doing code signing
1208; For some reason NSIS still finds the Uninstall section even
1209; when EXTERNAL_UNINSTALLER is defined. This causes a silly warning
1210;
1211!ifndef EXTERNAL_UNINSTALLER
1212
1213Function un.onUninstSuccess
1214
1215 HideWindow
1216 MessageBox MB_ICONINFORMATION|MB_OK $(VBOX_UNINST_SUCCESS) /SD IDOK
1217
1218FunctionEnd
1219
1220Function un.onInit
1221
1222 ; Has the user who calls us admin rights?
1223 UserInfo::GetAccountType
1224 Pop $0
1225 ${If} $0 != "Admin"
1226 MessageBox MB_ICONSTOP $(VBOX_NOADMIN) /SD IDOK
1227 Abort
1228 ${EndIf}
1229
1230 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 $(VBOX_UNINST_CONFIRM) /SD IDYES IDYES proceed
1231 Quit
1232
1233proceed:
1234
1235 Call un.SetAppMode64
1236
1237 ; Set system directory
1238 StrCpy $g_strSystemDir "$SYSDIR"
1239
1240 ; Retrieve Windows version we're running on and store it in $g_strWinVersion
1241 Call un.GetWindowsVer
1242
1243 ; Retrieve capabilities
1244 Call un.CheckForCapabilities
1245
1246FunctionEnd
1247
1248Section Uninstall
1249
1250!ifdef _DEBUG
1251 ; Enable logging
1252 Call un.EnableLog
1253!endif
1254
1255 Call un.SetAppMode64
1256
1257 ; Call the uninstall main function
1258 Call un.Uninstall
1259
1260 ; ... and remove the local install directory
1261 Call un.UninstallInstDir
1262
1263!ifndef _DEBUG
1264 SetAutoClose true
1265 MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 $(VBOX_REBOOT_REQUIRED) /SD IDNO IDYES restart
1266 StrCmp $g_bRebootOnExit "true" restart
1267!endif
1268
1269 Goto exit
1270
1271restart:
1272
1273 DetailPrint "Rebooting ..."
1274 Reboot
1275
1276exit:
1277
1278SectionEnd
1279
1280; !EXTERNAL_UNINSTALLER
1281!endif
1282
1283;Direct the output to our bin dir
1284!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