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