1 | @echo off
|
---|
2 | rem $Id: VBoxSFInst.cmd 93115 2022-01-01 11:31: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-2022 Oracle Corporation
|
---|
9 | rem
|
---|
10 | rem This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | rem available from http://www.virtualbox.org. This file is free software;
|
---|
12 | rem you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | rem General Public License (GPL) as published by the Free Software
|
---|
14 | rem Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | rem VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | rem hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | rem
|
---|
18 |
|
---|
19 |
|
---|
20 | setlocal ENABLEEXTENSIONS
|
---|
21 | setlocal
|
---|
22 |
|
---|
23 | rem
|
---|
24 | rem VBoxSF.sys should be in the same directory as this script or in the additions output dir.
|
---|
25 | rem
|
---|
26 | set MY_VBOXSF_SYS=%~dp0VBoxSF.sys
|
---|
27 | if exist "%MY_VBOXSF_SYS%" goto found_vboxsf
|
---|
28 | set MY_VBOXSF_SYS=%~dp0..\..\..\..\..\out\win.%KBUILD_TARGET_ARCH%\%KBUILD_TYPE%\bin\additions\VBoxSF.sys
|
---|
29 | if exist "%MY_VBOXSF_SYS%" goto found_vboxsf
|
---|
30 | echo VBoxSFInst.cmd: failed to find VBoxSF.sys in either "%~dp0" or "%~dp0..\..\..\..\..\out\win.%KBUILD_TARGET_ARCH%\%KBUILD_TYPE%\bin\additions\".
|
---|
31 | goto end
|
---|
32 | :found_vboxsf
|
---|
33 |
|
---|
34 | rem
|
---|
35 | rem VBoxMRXNP.dll should be in the same directory as this script or in the additions output dir.
|
---|
36 | rem
|
---|
37 | set MY_VBOXMRXNP_DLL=%~dp0VBoxMRXNP.dll
|
---|
38 | if exist "%MY_VBOXMRXNP_DLL%" goto found_vboxmrxnp
|
---|
39 | set MY_VBOXMRXNP_DLL=%~dp0..\..\..\..\..\out\win.%KBUILD_TARGET_ARCH%\%KBUILD_TYPE%\bin\additions\VBoxMRXNP.dll
|
---|
40 | if exist "%MY_VBOXMRXNP_DLL%" goto found_vboxmrxnp
|
---|
41 | echo VBoxSFInst.cmd: failed to find VBoxMRXNP.dll in either "%~dp0" or "%~dp0..\..\..\..\..\out\win.%KBUILD_TARGET_ARCH%\%KBUILD_TYPE%\bin\additions\".
|
---|
42 | goto end
|
---|
43 | :found_vboxmrxnp
|
---|
44 |
|
---|
45 | rem 32-bit version of same.
|
---|
46 | if not "%PROCESSOR_ARCHITECTURE%" == "AMD64" goto found_vboxmrxnp_x86
|
---|
47 | set MY_VBOXMRXNP_X86_DLL=%~dp0VBoxMRXNP-x86.dll
|
---|
48 | if exist "%MY_VBOXMRXNP_X86_DLL%" goto found_vboxmrxnp_x86
|
---|
49 | set MY_VBOXMRXNP_X86_DLL=%~dp0..\..\..\..\..\out\win.%KBUILD_TARGET_ARCH%\%KBUILD_TYPE%\bin\additions\VBoxMRXNP-x86.dll
|
---|
50 | if exist "%MY_VBOXMRXNP_X86_DLL%" goto found_vboxmrxnp_x86
|
---|
51 | echo VBoxSFInst.cmd: failed to find VBoxMRXNP-x86.dll in either "%~dp0" or "%~dp0..\..\..\..\..\out\win.%KBUILD_TARGET_ARCH%\%KBUILD_TYPE%\bin\additions\".
|
---|
52 | goto end
|
---|
53 | :found_vboxmrxnp_x86
|
---|
54 |
|
---|
55 | rem
|
---|
56 | rem VBoxDrvInst.exe should be in the same directory as this script or in the additions output dir.
|
---|
57 | rem
|
---|
58 | set MY_VBOXDRVINST=%~dp0VBoxDrvInst.exe
|
---|
59 | if exist "%MY_VBOXDRVINST%" goto found_vboxdrvinst
|
---|
60 | set MY_VBOXDRVINST=%~dp0..\..\..\..\..\out\win.%KBUILD_TARGET_ARCH%\%KBUILD_TYPE%\bin\additions\VBoxDrvInst.exe
|
---|
61 | if exist "%MY_VBOXDRVINST%" goto found_vboxdrvinst
|
---|
62 | echo VBoxSFInst.cmd: failed to find VBoxDrvInst.exe in either "%~dp0" or "%~dp0..\..\..\..\..\out\win.%KBUILD_TARGET_ARCH%\%KBUILD_TYPE%\bin\additions\".
|
---|
63 | goto end
|
---|
64 | :found_vboxdrvinst
|
---|
65 |
|
---|
66 | rem
|
---|
67 | rem Deregister the service, provider and delete old files.
|
---|
68 | rem
|
---|
69 | echo "Uninstalling..."
|
---|
70 | sc stop VBoxSF
|
---|
71 | reg delete /f "HKLM\SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" /v "DeviceName"
|
---|
72 | reg delete /f "HKLM\SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" /v "Name"
|
---|
73 | reg delete /f "HKLM\SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" /v "ProviderPath"
|
---|
74 |
|
---|
75 | "%MY_VBOXDRVINST%" service delete VBoxSF
|
---|
76 |
|
---|
77 | del "%SYSTEMROOT%\system32\drivers\VBoxSF.sys"
|
---|
78 | del "%SYSTEMROOT%\system32\VBoxMRXNP.dll"
|
---|
79 | if "%PROCESSOR_ARCHITECTURE%" == "AMD64" del "%SYSTEMROOT%\SysWOW64\VBoxMRXNP.dll"
|
---|
80 |
|
---|
81 |
|
---|
82 | rem
|
---|
83 | rem Install anything?
|
---|
84 | rem
|
---|
85 | if "%1" == "-u" goto end
|
---|
86 | if "%1" == "--uninstall" goto end
|
---|
87 |
|
---|
88 | rem
|
---|
89 | rem Copy the new files to the system dir.
|
---|
90 | rem
|
---|
91 | echo "Copying files..."
|
---|
92 | copy "%MY_VBOXSF_SYS%" "%SYSTEMROOT%\system32\drivers\"
|
---|
93 | copy "%MY_VBOXMRXNP_DLL%" "%SYSTEMROOT%\system32\"
|
---|
94 | if "%PROCESSOR_ARCHITECTURE%" == "AMD64" copy "%MY_VBOXMRXNP_X86_DLL%" "%SYSTEMROOT%\SysWow64\VBoxMRXNP.dll"
|
---|
95 |
|
---|
96 | rem
|
---|
97 | rem Register the service.
|
---|
98 | rem
|
---|
99 | echo "Installing service..."
|
---|
100 | "%MY_VBOXDRVINST%" service create VBoxSF "VirtualBox Shared Folders" 2 1 "%SYSTEMROOT%\System32\drivers\VBoxSF.sys" NetworkProvider
|
---|
101 |
|
---|
102 | echo "Configuring network provider..."
|
---|
103 | reg add "HKLM\SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" /v "DeviceName" /d "\Device\VBoxMiniRdr"
|
---|
104 | reg add "HKLM\SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" /v "Name" /d "VirtualBox Shared Folders"
|
---|
105 | reg add "HKLM\SYSTEM\CurrentControlSet\Services\VBoxSF\NetworkProvider" /v "ProviderPath" /d "%SYSTEMROOT%\System32\VBoxMRXNP.dll"
|
---|
106 |
|
---|
107 | "%MY_VBOXDRVINST%" netprovider add VBoxSF 0
|
---|
108 |
|
---|
109 | rem
|
---|
110 | rem Start the service?
|
---|
111 | rem
|
---|
112 | if "%1" == "-n" goto end
|
---|
113 | if "%1" == "--no-start" goto end
|
---|
114 | sc start VBoxSF
|
---|
115 |
|
---|
116 | :end
|
---|
117 | endlocal
|
---|
118 | endlocal
|
---|
119 |
|
---|