1 | @echo off
|
---|
2 | rem $Id: loadall.cmd 106833 2024-11-05 12:28:16Z vboxsync $
|
---|
3 | rem rem @file
|
---|
4 | rem Windows NT batch script for loading the host drivers.
|
---|
5 | rem
|
---|
6 |
|
---|
7 | rem
|
---|
8 | rem Copyright (C) 2009-2024 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 The contents of this file may alternatively be used under the terms
|
---|
27 | rem of the Common Development and Distribution License Version 1.0
|
---|
28 | rem (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
|
---|
29 | rem in the VirtualBox distribution, in which case the provisions of the
|
---|
30 | rem CDDL are applicable instead of those of the GPL.
|
---|
31 | rem
|
---|
32 | rem You may elect to license modified versions of this file under the
|
---|
33 | rem terms and conditions of either the GPL or the CDDL or both.
|
---|
34 | rem
|
---|
35 | rem SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
|
---|
36 | rem
|
---|
37 |
|
---|
38 |
|
---|
39 | setlocal ENABLEEXTENSIONS
|
---|
40 | setlocal ENABLEDELAYEDEXPANSION
|
---|
41 | setlocal
|
---|
42 |
|
---|
43 |
|
---|
44 | rem
|
---|
45 | rem find the directory we're in.
|
---|
46 | rem
|
---|
47 | set MY_DIR=%~dp0
|
---|
48 | if exist "%MY_DIR%\load.cmd" goto dir_okay
|
---|
49 | echo load.cmd: failed to find load.sh in "%~dp0".
|
---|
50 | goto end
|
---|
51 |
|
---|
52 | :dir_okay
|
---|
53 | rem
|
---|
54 | rem We don't use the driver files directly any more because of win10 keeping them
|
---|
55 | rem open, so create an alternative directory for the binaries. Another reason is
|
---|
56 | rem loading drivers via network shares, in which case we just use temp.
|
---|
57 | rem
|
---|
58 | set MY_ALTDIR=%MY_DIR%\..\LoadedDrivers
|
---|
59 | if not "%MY_ALTDIR:~1:1" == ":" goto alt_dir_remote
|
---|
60 | net use "%MY_ALTDIR:~0:1" > nul 2>nul && goto alt_dir_remote
|
---|
61 | goto alt_dir_done
|
---|
62 | :alt_dir_remote
|
---|
63 | set MY_ALTDIR=%TMP%\VBoxLoadedDrivers
|
---|
64 | :alt_dir_done
|
---|
65 | if not exist "%MY_ALTDIR%" mkdir "%MY_ALTDIR%"
|
---|
66 |
|
---|
67 | rem
|
---|
68 | rem Display device states.
|
---|
69 | rem
|
---|
70 | for %%i in (VBoxNetAdp VBoxNetAdp6 VBoxNetFlt VBoxNetLwf VBoxUSBMon VBoxUSB VBoxSup) do (
|
---|
71 | set type=
|
---|
72 | for /f "usebackq tokens=*" %%f in (`sc query %%i`) do (set xxx=%%f&&if "!xxx:~0,5!" =="STATE" set type=!xxx!)
|
---|
73 | for /f "usebackq tokens=2 delims=:" %%f in ('!type!') do set type=%%f
|
---|
74 | if "!type!x" == "x" set type= not configured, probably
|
---|
75 | echo load.sh: %%i -!type!
|
---|
76 | )
|
---|
77 |
|
---|
78 | rem
|
---|
79 | rem Copy uninstallers and installers and VBoxRT into the dir:
|
---|
80 | rem
|
---|
81 | echo **
|
---|
82 | echo ** Copying installers and uninstallers into %MY_ALTDIR%...
|
---|
83 | echo **
|
---|
84 | set MY_FAILED=no
|
---|
85 | for %%i in (NetAdpUninstall.exe NetAdp6Uninstall.exe USBUninstall.exe NetFltUninstall.exe NetLwfUninstall.exe SUPUninstall.exe ^
|
---|
86 | NetAdpInstall.exe NetAdp6Install.exe USBInstall.exe NetFltInstall.exe NetLwfInstall.exe SUPInstall.exe ^
|
---|
87 | VBoxRT.dll) do if exist "%MY_DIR%\%%i" (copy "%MY_DIR%\%%i" "%MY_ALTDIR%\%%i" || set MY_FAILED=yes)
|
---|
88 | if "%MY_FAILED%" == "yes" goto end
|
---|
89 |
|
---|
90 | rem
|
---|
91 | rem Unload the drivers.
|
---|
92 | rem
|
---|
93 | echo **
|
---|
94 | echo ** Unloading drivers...
|
---|
95 | echo **
|
---|
96 | for %%i in (NetAdpUninstall.exe NetAdp6Uninstall.exe USBUninstall.exe NetFltUninstall.exe NetLwfUninstall.exe SUPUninstall.exe) do (
|
---|
97 | if exist "%MY_ALTDIR%\%%i" (echo * Running %%i...&& "%MY_ALTDIR%\%%i")
|
---|
98 | )
|
---|
99 |
|
---|
100 | rem
|
---|
101 | rem Copy the driver files into the directory now that they no longer should be in use and can be overwritten.
|
---|
102 | rem
|
---|
103 | echo **
|
---|
104 | echo ** Copying drivers into %MY_ALTDIR%...
|
---|
105 | echo **
|
---|
106 | set MY_FAILED=no
|
---|
107 | for %%i in (^
|
---|
108 | VBoxSup.sys VBoxSup.inf VBoxSup.cat VBoxSup-PreW10.cat ^
|
---|
109 | VBoxNetAdp.sys VBoxNetAdp.inf VBoxNetAdp.cat ^
|
---|
110 | VBoxNetAdp6.sys VBoxNetAdp6.inf VBoxNetAdp6.cat VBoxNetAdp6-PreW10.cat ^
|
---|
111 | VBoxNetFlt.sys VBoxNetFlt.inf VBoxNetFlt.cat VBoxNetFltNobj.dll ^
|
---|
112 | VBoxNetFltM.inf ^
|
---|
113 | VBoxNetLwf.sys VBoxNetLwf.inf VBoxNetLwf.cat VBoxNetLwf-PreW10.cat ^
|
---|
114 | VBoxUSB.sys VBoxUSB.inf VBoxUSB.cat VBoxUSB-PreW10.cat ^
|
---|
115 | VBoxUSBMon.sys VBoxUSBMon.inf VBoxUSBMon.cat VBoxUSBMon-PreW10.cat ) ^
|
---|
116 | do if exist "%MY_DIR%\%%i" (copy "%MY_DIR%\%%i" "%MY_ALTDIR%\%%i" || set MY_FAILED=yes)
|
---|
117 | if "%MY_FAILED%" == "yes" goto end
|
---|
118 |
|
---|
119 | rem
|
---|
120 | rem Invoke the installer if asked to do so.
|
---|
121 | rem
|
---|
122 | if "%1%" == "-u" goto end
|
---|
123 | if "%1%" == "--uninstall" goto end
|
---|
124 |
|
---|
125 | set MY_VER=
|
---|
126 | for /f "usebackq delims=[] tokens=2" %%f in (`cmd /c ver`) do set MY_VER=%%f
|
---|
127 | for /f "usebackq tokens=2" %%f in ('%MY_VER%') do set MY_VER=%%f
|
---|
128 | for /f "usebackq delims=. tokens=1" %%f in ('%MY_VER%') do set MY_VER=%%f
|
---|
129 | set MY_VER=0000%MY_VER%
|
---|
130 | set MY_VER=%MY_VER:~-2%
|
---|
131 |
|
---|
132 | echo **
|
---|
133 | echo ** Loading drivers (for windows version %MY_VER%)...
|
---|
134 | echo **
|
---|
135 |
|
---|
136 | if "%MY_VER%" GEQ "06" (
|
---|
137 | set MY_INSTALLERS=SUPInstall.exe USBInstall.exe NetLwfInstall.exe NetAdp6Install.exe
|
---|
138 | ) else (
|
---|
139 | set MY_INSTALLERS=SUPInstall.exe USBInstall.exe NetFltInstall.exe
|
---|
140 | rem NetAdpInstall.exe; - busted
|
---|
141 | )
|
---|
142 | for %%i in (%MY_INSTALLERS%) do (echo * Running %%i...&& "%MY_ALTDIR%\%%i" || (echo loadall.cmd: %%i failed&& goto end))
|
---|
143 |
|
---|
144 | echo * loadall.cmd completed successfully.
|
---|
145 | :end
|
---|
146 | endlocal
|
---|
147 | endlocal
|
---|
148 | endlocal
|
---|
149 |
|
---|