1 | @echo off
|
---|
2 | rem $Id: VBoxSFInst.cmd 98103 2023-01-17 14:15:46Z vboxsync $
|
---|
3 | rem rem @file
|
---|
4 | rem Windows NT batch script for manually installing the shared folders guest addition driver.
|
---|
5 | rem
|
---|
6 |
|
---|
7 | rem
|
---|
8 | rem Copyright (C) 2009-2023 Oracle and/or its affiliates.
|
---|
9 | rem
|
---|
10 | rem This file is part of VirtualBox base platform packages, as
|
---|
11 | rem available from https://www.virtualbox.org.
|
---|
12 | rem
|
---|
13 | rem This program is free software; you can redistribute it and/or
|
---|
14 | rem modify it under the terms of the GNU General Public License
|
---|
15 | rem as published by the Free Software Foundation, in version 3 of the
|
---|
16 | rem License.
|
---|
17 | rem
|
---|
18 | rem This program is distributed in the hope that it will be useful, but
|
---|
19 | rem WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
20 | rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
21 | rem General Public License for more details.
|
---|
22 | rem
|
---|
23 | rem You should have received a copy of the GNU General Public License
|
---|
24 | rem along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
25 | rem
|
---|
26 | rem SPDX-License-Identifier: GPL-3.0-only
|
---|
27 | rem
|
---|
28 |
|
---|
29 |
|
---|
30 | setlocal ENABLEEXTENSIONS
|
---|
31 | setlocal
|
---|
32 |
|
---|
33 | rem
|
---|
34 | rem VBoxSF.sys should be in the same directory as this script or in the additions output dir.
|
---|
35 | rem
|
---|
36 | set MY_VBOXSF_SYS=%~dp0VBoxSF.sys
|
---|
37 | if exist "%MY_VBOXSF_SYS%" goto found_vboxsf
|
---|
38 | set MY_VBOXSF_SYS=%~dp0..\..\..\..\..\out\win.%KBUILD_TARGET_ARCH%\%KBUILD_TYPE%\bin\additions\VBoxSF.sys
|
---|
39 | if exist "%MY_VBOXSF_SYS%" goto found_vboxsf
|
---|
40 | echo VBoxSFInst.cmd: failed to find VBoxSF.sys in either "%~dp0" or "%~dp0..\..\..\..\..\out\win.%KBUILD_TARGET_ARCH%\%KBUILD_TYPE%\bin\additions\".
|
---|
41 | goto end
|
---|
42 | :found_vboxsf
|
---|
43 |
|
---|
44 | rem
|
---|
45 | rem VBoxMRXNP.dll should be in the same directory as this script or in the additions output dir.
|
---|
46 | rem
|
---|
47 | set MY_VBOXMRXNP_DLL=%~dp0VBoxMRXNP.dll
|
---|
48 | if exist "%MY_VBOXMRXNP_DLL%" goto found_vboxmrxnp
|
---|
49 | set MY_VBOXMRXNP_DLL=%~dp0..\..\..\..\..\out\win.%KBUILD_TARGET_ARCH%\%KBUILD_TYPE%\bin\additions\VBoxMRXNP.dll
|
---|
50 | if exist "%MY_VBOXMRXNP_DLL%" goto found_vboxmrxnp
|
---|
51 | echo VBoxSFInst.cmd: failed to find VBoxMRXNP.dll in either "%~dp0" or "%~dp0..\..\..\..\..\out\win.%KBUILD_TARGET_ARCH%\%KBUILD_TYPE%\bin\additions\".
|
---|
52 | goto end
|
---|
53 | :found_vboxmrxnp
|
---|
54 |
|
---|
55 | rem 32-bit version of same.
|
---|
56 | if not "%PROCESSOR_ARCHITECTURE%" == "AMD64" goto found_vboxmrxnp_x86
|
---|
57 | set MY_VBOXMRXNP_X86_DLL=%~dp0VBoxMRXNP-x86.dll
|
---|
58 | if exist "%MY_VBOXMRXNP_X86_DLL%" goto found_vboxmrxnp_x86
|
---|
59 | set MY_VBOXMRXNP_X86_DLL=%~dp0..\..\..\..\..\out\win.%KBUILD_TARGET_ARCH%\%KBUILD_TYPE%\bin\additions\VBoxMRXNP-x86.dll
|
---|
60 | if exist "%MY_VBOXMRXNP_X86_DLL%" goto found_vboxmrxnp_x86
|
---|
61 | echo VBoxSFInst.cmd: failed to find VBoxMRXNP-x86.dll in either "%~dp0" or "%~dp0..\..\..\..\..\out\win.%KBUILD_TARGET_ARCH%\%KBUILD_TYPE%\bin\additions\".
|
---|
62 | goto end
|
---|
63 | :found_vboxmrxnp_x86
|
---|
64 |
|
---|
65 | rem
|
---|
66 | rem VBoxDrvInst.exe should be in the same directory as this script or in the additions output dir.
|
---|
67 | rem
|
---|
68 | set MY_VBOXDRVINST=%~dp0VBoxDrvInst.exe
|
---|
69 | if exist "%MY_VBOXDRVINST%" goto found_vboxdrvinst
|
---|
70 | set MY_VBOXDRVINST=%~dp0..\..\..\..\..\out\win.%KBUILD_TARGET_ARCH%\%KBUILD_TYPE%\bin\additions\VBoxDrvInst.exe
|
---|
71 | if exist "%MY_VBOXDRVINST%" goto found_vboxdrvinst
|
---|
72 | echo VBoxSFInst.cmd: failed to find VBoxDrvInst.exe in either "%~dp0" or "%~dp0..\..\..\..\..\out\win.%KBUILD_TARGET_ARCH%\%KBUILD_TYPE%\bin\additions\".
|
---|
73 | goto end
|
---|
74 | :found_vboxdrvinst
|
---|
75 |
|
---|
76 | rem
|
---|
77 | rem Deregister the service, provider and delete old files.
|
---|
78 | rem
|
---|
79 | echo "Uninstalling..."
|
---|
80 | sc stop VBoxSF
|
---|
81 | reg delete /f "HKLM\SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" /v "DeviceName"
|
---|
82 | reg delete /f "HKLM\SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" /v "Name"
|
---|
83 | reg delete /f "HKLM\SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" /v "ProviderPath"
|
---|
84 |
|
---|
85 | "%MY_VBOXDRVINST%" service delete VBoxSF
|
---|
86 |
|
---|
87 | del "%SYSTEMROOT%\system32\drivers\VBoxSF.sys"
|
---|
88 | del "%SYSTEMROOT%\system32\VBoxMRXNP.dll"
|
---|
89 | if "%PROCESSOR_ARCHITECTURE%" == "AMD64" del "%SYSTEMROOT%\SysWOW64\VBoxMRXNP.dll"
|
---|
90 |
|
---|
91 |
|
---|
92 | rem
|
---|
93 | rem Install anything?
|
---|
94 | rem
|
---|
95 | if "%1" == "-u" goto end
|
---|
96 | if "%1" == "--uninstall" goto end
|
---|
97 |
|
---|
98 | rem
|
---|
99 | rem Copy the new files to the system dir.
|
---|
100 | rem
|
---|
101 | echo "Copying files..."
|
---|
102 | copy "%MY_VBOXSF_SYS%" "%SYSTEMROOT%\system32\drivers\"
|
---|
103 | copy "%MY_VBOXMRXNP_DLL%" "%SYSTEMROOT%\system32\"
|
---|
104 | if "%PROCESSOR_ARCHITECTURE%" == "AMD64" copy "%MY_VBOXMRXNP_X86_DLL%" "%SYSTEMROOT%\SysWow64\VBoxMRXNP.dll"
|
---|
105 |
|
---|
106 | rem
|
---|
107 | rem Register the service.
|
---|
108 | rem
|
---|
109 | echo "Installing service..."
|
---|
110 | "%MY_VBOXDRVINST%" service create VBoxSF "VirtualBox Shared Folders" 2 1 "%SYSTEMROOT%\System32\drivers\VBoxSF.sys" NetworkProvider
|
---|
111 |
|
---|
112 | echo "Configuring network provider..."
|
---|
113 | reg add "HKLM\SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" /v "DeviceName" /d "\Device\VBoxMiniRdr"
|
---|
114 | reg add "HKLM\SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" /v "Name" /d "VirtualBox Shared Folders"
|
---|
115 | reg add "HKLM\SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" /v "ProviderPath" /d "%SYSTEMROOT%\System32\VBoxMRXNP.dll"
|
---|
116 |
|
---|
117 | "%MY_VBOXDRVINST%" netprovider add VBoxSF 0
|
---|
118 |
|
---|
119 | rem
|
---|
120 | rem Start the service?
|
---|
121 | rem
|
---|
122 | if "%1" == "-n" goto end
|
---|
123 | if "%1" == "--no-start" goto end
|
---|
124 | sc start VBoxSF
|
---|
125 |
|
---|
126 | :end
|
---|
127 | endlocal
|
---|
128 | endlocal
|
---|
129 |
|
---|