VBoxGuestAdditions.nsi revision 168f0d5dcd9366f5e1c22fcc49f8dc5a20d4686e
5f0e2c8913fed44e1629f1367ce54e74ce2a2eb3Michael Graff; VBoxGuestAdditions.nsi - Main file for Windows Guest Additions installation.
5f0e2c8913fed44e1629f1367ce54e74ce2a2eb3Michael Graff; Copyright (C) 2012-2013 Oracle Corporation
5f0e2c8913fed44e1629f1367ce54e74ce2a2eb3Michael Graff; This file is part of VirtualBox Open Source Edition (OSE), as
5f0e2c8913fed44e1629f1367ce54e74ce2a2eb3Michael Graff; available from http://www.virtualbox.org. This file is free software;
5f0e2c8913fed44e1629f1367ce54e74ce2a2eb3Michael Graff; you can redistribute it and/or modify it under the terms of the GNU
5f0e2c8913fed44e1629f1367ce54e74ce2a2eb3Michael Graff; General Public License (GPL) as published by the Free Software
5f0e2c8913fed44e1629f1367ce54e74ce2a2eb3Michael Graff; Foundation, in version 2 as it comes in the "COPYING" file of the
5f0e2c8913fed44e1629f1367ce54e74ce2a2eb3Michael Graff; VirtualBox OSE distribution. VirtualBox OSE is distributed in the
5f0e2c8913fed44e1629f1367ce54e74ce2a2eb3Michael Graff; hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!if $%BUILD_TYPE% == "debug"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !define _DEBUG ; Turn this on to get extra output
332d9b3837c2289313bb93aa7d9e955900c13660Bob Halley!ifdef _DEBUG
2b9515f49789f24f18d8f6dee9cce1d7ba7b0d33Andreas Gustafsson ; Scratch directory for plugin tests
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !addincludedir .\PluginTest
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !addplugindir .\PluginTest
332d9b3837c2289313bb93aa7d9e955900c13660Bob Halley; Defines for special functions
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!define WHQL_FAKE ; Enables faking of non WHQL signed / approved drivers
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff ; Needs the VBoxWHQLFake.exe in the additions output directory!
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!define WFP_FILE_EXCEPTION ; Enables setting a temporary file exception for WFP proctected files
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!define VENDOR_ROOT_KEY "SOFTWARE\$%VBOX_VENDOR_SHORT%"
212e466f42f7d29ffb02eb9d6a9938136d07c9d9Michael Graff; Product defines
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!define PRODUCT_NAME "$%VBOX_PRODUCT% Guest Additions"
9e9630facafe8b1a0ea6456ab5f9c72919654802Michael Graff!define PRODUCT_DESC "$%VBOX_PRODUCT% Guest Additions"
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff!define PRODUCT_VERSION "$%VBOX_VERSION_MAJOR%.$%VBOX_VERSION_MINOR%.$%VBOX_VERSION_BUILD%.0"
9e9630facafe8b1a0ea6456ab5f9c72919654802Michael Graff!define PRODUCT_PUBLISHER "$%VBOX_VENDOR%"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!define PRODUCT_COPYRIGHT "(C) $%VBOX_C_YEAR% $%VBOX_VENDOR%"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!define PRODUCT_OUTPUT "VBoxWindowsAdditions-$%BUILD_TARGET_ARCH%.exe"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!define PRODUCT_WEB_SITE "http://www.virtualbox.org"
9e9630facafe8b1a0ea6456ab5f9c72919654802Michael Graff!define PRODUCT_INSTALL_KEY "${VENDOR_ROOT_KEY}\VirtualBox Guest Additions"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!define PRODUCT_UNINST_KEY "Software\Microsoft\Windows\CurrentVersion\Uninstall\${PRODUCT_NAME}"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!define PRODUCT_UNINST_ROOT_KEY "HKLM"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!define LICENSE_FILE_RTF "license.rtf"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff; Needed for InstallLib macro: Install libraries in every case
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!define LIBRARY_IGNORE_VERSION
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael GraffVIProductVersion "${PRODUCT_VERSION}"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael GraffVIAddVersionKey "FileVersion" "$%VBOX_VERSION_STRING%"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael GraffVIAddVersionKey "ProductName" "${PRODUCT_NAME}"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael GraffVIAddVersionKey "ProductVersion" "${PRODUCT_VERSION}"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael GraffVIAddVersionKey "CompanyName" "${PRODUCT_PUBLISHER}"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael GraffVIAddVersionKey "FileDescription" "${PRODUCT_DESC}"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael GraffVIAddVersionKey "LegalCopyright" "${PRODUCT_COPYRIGHT}"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael GraffVIAddVersionKey "InternalName" "${PRODUCT_OUTPUT}"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff; This registry key will hold the mouse driver path before install (NT4 only)
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!define ORG_MOUSE_PATH "MousePath"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff; If we have our guest install helper DLL, add the
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff; plugin path so that NSIS can find it when compiling the installer
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff; Note: NSIS plugins *always* have to be compiled in 32-bit!
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!if $%VBOX_WITH_GUEST_INSTALL_HELPER% == "1"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !addplugindir "$%PATH_TARGET_X86%\VBoxGuestInstallHelper"
3ddd814a97de1d152ba0913c592d6e6dc83d38a6Michael Graff !insertmacro GetParameters
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !insertmacro GetOptions
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !insertmacro WordFind
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !insertmacro StrFilter
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!include "strstr.nsh" ; Function "strstr"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!include "servicepack.nsh" ; Function "GetServicePack"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!include "winver.nsh" ; Function for determining Windows version
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!define REPLACEDLL_NOREGISTER ; Replace in use DLL function
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!include "dumplog.nsh" ; Dump log to file function
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!if $%BUILD_TARGET_ARCH% == "amd64"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff; Set Modern UI (MUI) as default
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!define USE_MUI
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!ifdef USE_MUI
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff ; Use modern UI, version 2
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff ; MUI Settings
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !define MUI_WELCOMEFINISHPAGE_BITMAP "$%VBOX_BRAND_WIN_ADD_INST_DLGBMP%"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !define MUI_ABORTWARNING
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !define MUI_WELCOMEPAGE_TITLE_3LINES "Welcome to the ${PRODUCT_NAME} Additions Setup"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff ; API defines
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !define SM_CLEANBOOT 67
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !if $%BUILD_TARGET_ARCH% == "x86" ; 32-bit
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !define MUI_ICON "$%VBOX_NSIS_ICON_FILE%"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !define MUI_UNICON "$%VBOX_NSIS_ICON_FILE%"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !else ; 64-bit
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !define MUI_ICON "$%VBOX_WINDOWS_ADDITIONS_ICON_FILE%"
9e9630facafe8b1a0ea6456ab5f9c72919654802Michael Graff !define MUI_UNICON "$%VBOX_WINDOWS_ADDITIONS_ICON_FILE%"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff ; Welcome page
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !insertmacro MUI_PAGE_WELCOME
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff!ifdef VBOX_WITH_LICENSE_DISPLAY
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff ; License page
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !insertmacro MUI_PAGE_LICENSE "$(VBOX_LICENSE)"
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !define MUI_LICENSEPAGE_RADIOBUTTONS
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff ; Directory page
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !insertmacro MUI_PAGE_DIRECTORY
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff ; Components Page
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !insertmacro MUI_PAGE_COMPONENTS
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff ; Instfiles page
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !insertmacro MUI_PAGE_INSTFILES
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !ifndef _DEBUG
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !define MUI_FINISHPAGE_TITLE_3LINES ; Have a bit more vertical space for text
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !insertmacro MUI_PAGE_FINISH ; Only show in release mode - useful information for debugging!
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff ; Uninstaller pages
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff !insertmacro MUI_UNPAGE_INSTFILES
9df93ea1bf53e09fd2d7f13c899817046dd04325Michael Graff ; Define languages we will use
!include "Languages\English.nsh"
!include "Languages\French.nsh"
!include "Languages\German.nsh"
OutFile "$%PATH_TARGET%\VBoxWindowsAdditions-$%BUILD_TARGET_ARCH%-uninst.exe"
Var g_iSystemMode ; Current system mode (0 = Normal boot, 1 = Fail-safe boot, 2 = Fail-safe with network boot)
Var g_bCapDllCache ; Capability: Does the (Windows) guest have have a DLL cache which needs to be taken care of?
Var g_bCapWDDM ; Capability: Is the guest able to handle/use our WDDM driver?
; Command line parameters - these can be set/modified
Var g_bFakeWHQL ; Cmd line: Fake Windows to install non WHQL certificated drivers (only for W2K and XP currently!!) ("/unsig_drv")
Var g_bRebootOnExit ; Cmd line: Auto-Reboot on successful installation. Good for unattended installations ("/reboot")
Var g_bNoVBoxServiceExit ; Cmd line: Do not quit VBoxService before updating - install on next reboot
Var g_bOnlyExtract ; Cmd line: Only extract all files, do *not* install them. Only valid with param "/D" (target directory)
Var g_bPostInstallStatus ; Cmd line: Post the overall installation status to some external program (VBoxTray)
!include "VBoxGuestAdditionsLog.nsh"
!include "VBoxGuestAdditionsExternal.nsh"
!include "VBoxGuestAdditionsCommon.nsh"
!include "VBoxGuestAdditionsNT4.nsh"
!include "VBoxGuestAdditionsW2KXP.nsh"
!include "VBoxGuestAdditionsVista.nsh"
!include "VBoxGuestAdditionsUninstall.nsh" ; Product uninstallation
!include "VBoxGuestAdditionsUninstallOld.nsh" ; Uninstallation of deprecated versions which must be removed first
/force$\t$\tForce installation on unknown/undetected Windows versions$\r$\n \
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Sun VirtualBox Guest Additions" "UninstallString"
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Sun xVM VirtualBox Guest Additions" "UninstallString"
StrCmp $0 "" innotek_check ; If string is empty, Sun xVM additions are probably not installed (anymore)
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\innotek VirtualBox Guest Additions" "UninstallString"
StrCmp $0 "" exit ; If string is empty, innotek Guest Additions are probably not installed (anymore)
${If} $0 == "VBoxGINA.dll"
ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\Credential Providers\{275D3BCC-22BB-4948-A7F6-3A3054EBA92B}" ""
${If} ${FileExists} "$g_strSystemDir\VBoxMMR.exe"
${AndIf} ${FileExists} "$g_strSysWow64\VBoxMMRHook.dll"
${AndIf} ${FileExists} "$g_strSystemDir\VBoxMMRHook.dll"
${LogVerbose} "Previous version: $g_strAddVerMaj.$g_strAddVerMin.$g_strAddVerBuild (Rev $g_strAddVerRev)"
; Auto-logon support (section is hidden at the moment -- only can be enabled via command line switch)
; Another GINA already is installed? Check if this is ours, otherwise let the user decide (unless it's a silent setup)
${If} $0 != "VBoxGINA.dll"
MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON1 $(VBOX_COMPONENT_AUTOLOGON_WARN_3RDPARTY) /SD IDYES IDYES install
!insertmacro ReplaceDLL "$%PATH_OUT%\bin\additions\VBoxCredProv.dll" "$g_strSystemDir\VBoxCredProv.dll" "$INSTDIR"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\Credential Providers\{275D3BCC-22BB-4948-A7F6-3A3054EBA92B}" "" "VBoxCredProv" ; adding to (default) key
WriteRegStr HKCR "CLSID\{275D3BCC-22BB-4948-A7F6-3A3054EBA92B}" "" "VBoxCredProv" ; adding to (Default) key
WriteRegStr HKCR "CLSID\{275D3BCC-22BB-4948-A7F6-3A3054EBA92B}\InprocServer32" "" "VBoxCredProv.dll" ; adding to (Default) key
WriteRegStr HKCR "CLSID\{275D3BCC-22BB-4948-A7F6-3A3054EBA92B}\InprocServer32" "ThreadingModel" "Apartment"
!insertmacro ReplaceDLL "$%PATH_OUT%\bin\additions\VBoxGINA.dll" "$g_strSystemDir\VBoxGINA.dll" "$INSTDIR"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon" "GinaDLL" "VBoxGINA.dll"
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\VBoxGINA" "DLLName" "VBoxGINA.dll"
WriteRegDWORD HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\VBoxGINA" "Impersonate" 0
WriteRegStr HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion\WinLogon\Notify\VBoxGINA" "StopScreenSaver" "WnpScreenSaverStop"
${If} ${FileExists} "$g_strSystemDir\takeown.exe"
${CmdExecute} "$\"$g_strSystemDir\takeown.exe$\" /F $\"$0$\"" "true"
${LogVerbose} "WRP: Warning: takeown.exe not found, skipping"
FILE "$%PATH_OUT%\bin\additions\VBoxD3D8.dll"
FILE "$%PATH_OUT%\bin\additions\VBoxD3D9.dll"
FILE "$%PATH_OUT%\bin\additions\wined3d.dll"
${CopyFileEx} "" "$g_strSystemDir\dllcache\d3d8.dll" "$g_strSystemDir\dllcache\msd3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
${CopyFileEx} "" "$g_strSystemDir\dllcache\d3d9.dll" "$g_strSystemDir\dllcache\msd3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
Push "$g_strSystemDir\dllcache\d3d8.dll"
Push "$g_strSystemDir\dllcache\d3d9.dll"
${InstallFileEx} "" "$%PATH_OUT%\bin\additions\d3d8.dll" "$g_strSystemDir\dllcache\d3d8.dll" "$TEMP"
${InstallFileEx} "" "$%PATH_OUT%\bin\additions\d3d9.dll" "$g_strSystemDir\dllcache\d3d9.dll" "$TEMP"
${CopyFileEx} "" "$g_strSystemDir\d3d8.dll" "$g_strSystemDir\msd3d8.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
${CopyFileEx} "" "$g_strSystemDir\d3d9.dll" "$g_strSystemDir\msd3d9.dll" "Microsoft Corporation" "$%BUILD_TARGET_ARCH%"
Push "$g_strSystemDir\d3d8.dll"
Push "$g_strSystemDir\d3d9.dll"
FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxD3D8.dll"
FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\VBoxD3D9.dll"
FILE "$%VBOX_PATH_ADDITIONS_WIN_X86%\wined3d.dll"
${CopyFileEx} "" "$g_strSysWow64\dllcache\d3d8.dll" "$g_strSysWow64\dllcache\msd3d8.dll" "Microsoft Corporation" "x86"
${CopyFileEx} "" "$g_strSysWow64\dllcache\d3d9.dll" "$g_strSysWow64\dllcache\msd3d9.dll" "Microsoft Corporation" "x86"
Push "$g_strSysWow64\dllcache\d3d8.dll"
Push "$g_strSysWow64\dllcache\d3d9.dll"
${InstallFileEx} "" "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d8.dll" "$g_strSysWow64\dllcache\d3d8.dll" "$TEMP"
${InstallFileEx} "" "$%VBOX_PATH_ADDITIONS_WIN_X86%\d3d9.dll" "$g_strSysWow64\dllcache\d3d9.dll" "$TEMP"
${CopyFileEx} "" "$g_strSysWow64\d3d8.dll" "$g_strSysWow64\msd3d8.dll" "Microsoft Corporation" "x86"
${CopyFileEx} "" "$g_strSysWow64\d3d9.dll" "$g_strSysWow64\msd3d9.dll" "Microsoft Corporation" "x86"
Push "$g_strSysWow64\d3d8.dll"
Push "$g_strSysWow64\d3d9.dll"
CreateShortCut "$SMPROGRAMS\${PRODUCT_NAME}\Website.lnk" "$INSTDIR\${PRODUCT_NAME}.url" "" "$INSTDIR\iexplore.ico"
FILE "$%PATH_TARGET%\uninst.exe"
WriteUninstaller "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "UninstallString" "$INSTDIR\uninst.exe"
WriteRegStr ${PRODUCT_UNINST_ROOT_KEY} "${PRODUCT_UNINST_KEY}" "DisplayVersion" "${PRODUCT_VERSION}"
; If UNINSTALLER_ONLY is defined, we're only interested in uninst.exe
WriteUninstaller "$%PATH_TARGET%\uninst.exe"
Function un.onUninstSuccess
Function un.onInit
Call un.SetAppMode64
Call un.SetAppMode64
Call un.Uninstall
Call un.UninstallInstDir