-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.bat
More file actions
51 lines (44 loc) · 1.18 KB
/
setup.bat
File metadata and controls
51 lines (44 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
@echo off
setlocal enabledelayedexpansion
:: Enable error checking
set "EXITCODE=0"
:: List all connected USB devices using usbipd list
echo Listing all USB devices...
for /f "tokens=*" %%A in ('usbipd list') do (
echo %%A
)
if %errorlevel% neq 0 (
echo Error: usbipd list command failed.
exit /b %errorlevel%
)
:: Prompt user for the Bus ID
set /p busid="Enter the Bus ID of the device you want to forward to WSL (e.g., 4-2): "
if "%busid%"=="" (
echo Error: Bus ID is required.
exit /b 1
)
echo Selected Bus ID: %busid%
:: Bind the selected device
echo Binding the device with Bus ID %busid% to WSL...
usbipd bind --busid %busid%
if %errorlevel% neq 0 (
echo Error: usbipd bind command failed.
exit /b %errorlevel%
)
:: Attach the device to WSL
echo Attaching the device to WSL...
usbipd attach --wsl --busid %busid%
if %errorlevel% neq 0 (
echo Error: usbipd attach command failed.
exit /b %errorlevel%
)
:: Verify device is attached
echo Verify the device is attached...
usbipd list
if %errorlevel% neq 0 (
echo Error: usbipd list command failed after attaching device.
exit /b %errorlevel%
)
echo USB device successfully attached to WSL.
endlocal
pause