VirtualBox

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

Last change on this file since 36311 was 36311, checked in by vboxsync, 14 years ago

Windows Guest Additions installer: Check if VBoxGINA already is installed and do an automated upgrade (whether /with_autologon is specified or not), put app mode (32-/64-bit) switching in own function.

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