VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/win/loadall.cmd@ 106833

Last change on this file since 106833 was 106833, checked in by vboxsync, 3 weeks ago

HostDrivers/win: Adjusted load.cmd and loadall.cmd to detect network drives and load the drivers off C:\Users\bird\AppData\Local\Temp instead. jiraref:VBP-1253

  • Property svn:eol-style set to CRLF
  • Property svn:keywords set to Author Date Id Revision
File size: 5.3 KB
Line 
1@echo off
2rem $Id: loadall.cmd 106833 2024-11-05 12:28:16Z vboxsync $
3rem rem @file
4rem Windows NT batch script for loading the host drivers.
5rem
6
7rem
8rem Copyright (C) 2009-2024 Oracle and/or its affiliates.
9rem
10rem This file is part of VirtualBox base platform packages, as
11rem available from https://www.virtualbox.org.
12rem
13rem This program is free software; you can redistribute it and/or
14rem modify it under the terms of the GNU General Public License
15rem as published by the Free Software Foundation, in version 3 of the
16rem License.
17rem
18rem This program is distributed in the hope that it will be useful, but
19rem WITHOUT ANY WARRANTY; without even the implied warranty of
20rem MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21rem General Public License for more details.
22rem
23rem You should have received a copy of the GNU General Public License
24rem along with this program; if not, see <https://www.gnu.org/licenses>.
25rem
26rem The contents of this file may alternatively be used under the terms
27rem of the Common Development and Distribution License Version 1.0
28rem (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
29rem in the VirtualBox distribution, in which case the provisions of the
30rem CDDL are applicable instead of those of the GPL.
31rem
32rem You may elect to license modified versions of this file under the
33rem terms and conditions of either the GPL or the CDDL or both.
34rem
35rem SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
36rem
37
38
39setlocal ENABLEEXTENSIONS
40setlocal ENABLEDELAYEDEXPANSION
41setlocal
42
43
44rem
45rem find the directory we're in.
46rem
47set MY_DIR=%~dp0
48if exist "%MY_DIR%\load.cmd" goto dir_okay
49echo load.cmd: failed to find load.sh in "%~dp0".
50goto end
51
52:dir_okay
53rem
54rem We don't use the driver files directly any more because of win10 keeping them
55rem open, so create an alternative directory for the binaries. Another reason is
56rem loading drivers via network shares, in which case we just use temp.
57rem
58set MY_ALTDIR=%MY_DIR%\..\LoadedDrivers
59if not "%MY_ALTDIR:~1:1" == ":" goto alt_dir_remote
60net use "%MY_ALTDIR:~0:1" > nul 2>nul && goto alt_dir_remote
61goto alt_dir_done
62:alt_dir_remote
63set MY_ALTDIR=%TMP%\VBoxLoadedDrivers
64:alt_dir_done
65if not exist "%MY_ALTDIR%" mkdir "%MY_ALTDIR%"
66
67rem
68rem Display device states.
69rem
70for %%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
78rem
79rem Copy uninstallers and installers and VBoxRT into the dir:
80rem
81echo **
82echo ** Copying installers and uninstallers into %MY_ALTDIR%...
83echo **
84set MY_FAILED=no
85for %%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)
88if "%MY_FAILED%" == "yes" goto end
89
90rem
91rem Unload the drivers.
92rem
93echo **
94echo ** Unloading drivers...
95echo **
96for %%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
100rem
101rem Copy the driver files into the directory now that they no longer should be in use and can be overwritten.
102rem
103echo **
104echo ** Copying drivers into %MY_ALTDIR%...
105echo **
106set MY_FAILED=no
107for %%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 ) ^
116do if exist "%MY_DIR%\%%i" (copy "%MY_DIR%\%%i" "%MY_ALTDIR%\%%i" || set MY_FAILED=yes)
117if "%MY_FAILED%" == "yes" goto end
118
119rem
120rem Invoke the installer if asked to do so.
121rem
122if "%1%" == "-u" goto end
123if "%1%" == "--uninstall" goto end
124
125set MY_VER=
126for /f "usebackq delims=[] tokens=2" %%f in (`cmd /c ver`) do set MY_VER=%%f
127for /f "usebackq tokens=2" %%f in ('%MY_VER%') do set MY_VER=%%f
128for /f "usebackq delims=. tokens=1" %%f in ('%MY_VER%') do set MY_VER=%%f
129set MY_VER=0000%MY_VER%
130set MY_VER=%MY_VER:~-2%
131
132echo **
133echo ** Loading drivers (for windows version %MY_VER%)...
134echo **
135
136if "%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)
142for %%i in (%MY_INSTALLERS%) do (echo * Running %%i...&& "%MY_ALTDIR%\%%i" || (echo loadall.cmd: %%i failed&& goto end))
143
144echo * loadall.cmd completed successfully.
145:end
146endlocal
147endlocal
148endlocal
149
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette