(view source code of renewusb.bat as plain text)
@ECHO OFF
:: Check Windows version
IF NOT "%OS%"=="Windows_NT" GOTO Syntax
IF "%OS%"=="Windows_NT" SETLOCAL
VER | FIND "Windows NT" >NUL && GOTO Syntax
:: Check command line arguments -- none required
IF NOT "%~1"=="" GOTO Syntax
:: Check if DEVCON.EXE is available and if not, prompt for download
SET DevconAvailable=
SET Download=
DEVCON.EXE /? >NUL 2>&1
IF ERRORLEVEL 1 (
SET DevconAvailable=No
ECHO This batch file requires Microsoft's DEVCON untility.
SET /P Download=Do you want to download it now? [y/N]
)
:: Start download if requested
IF /I "%Download%"=="Y" (
START "WDK" https://www.microsoft.com/en-us/download/details.aspx?id=11800
ECHO.
ECHO Install the downloaded WDK, or read
ECHO http://www.robvanderwoude.com/devcon.php
ECHO to find out how to install DEVCON.EXE only.
ECHO Make sure DEVCON.EXE is in the PATH, then try again.
)
:: Abort if DEVCON.EXE is not available yet
IF "%DevconAvailable%"=="No" GOTO End
:: List and remove all USB devices
>> RenewUSB.dat ECHO.%Date%, %Time%
DEVCON FindAll =USB | FIND ":" >> RenewUSB.dat
FOR /F "tokens=1 delims=: " %%A IN ('DEVCON FindAll ^=USB ^| FIND ":"') DO DEVCON Remove "@%%A"
DEVCON FindAll USB* | FIND ":" >> RenewUSB.dat
FOR /F "tokens=1 delims=: " %%A IN ('DEVCON FindAll USB* ^| FIND ":"') DO DEVCON Remove "@%%A"
:: Rescan for new hardware
DEVCON ReScan
:: Done
ENDLOCAL
GOTO End
:Syntax
ECHO.
ECHO RenewUSB.bat, Version 1.01 for Windows 2000 / XP
ECHO Use DEVCON to remove all USB devices and then scan for new devices
ECHO.
ECHO Usage: RENEWUSB
ECHO.
ECHO Notes: [1] This batch file requires Microsoft's DEVCON utility,
ECHO part of the Windows Driver Kit ^(WDK^), available at
ECHO https://www.microsoft.com/en-us/download/details.aspx?id=11800
ECHO You will be prompted for download if it isn't found.
ECHO [2] This batch file requires elevated privileges.
ECHO [3] I tested this batch file on my own PC running Windows 2000 Pro SP4.
ECHO However, I cannot guarantee flawless operation on any other PC.
ECHO Use this batch file entirely at your own risk. Make sure you have
ECHO a recent full backup available in case something might go wrong.
ECHO [4] Before removal each USB device is logged in RENEWUSB.DAT.
ECHO.
ECHO Written by Rob van der Woude
ECHO http://www.robvanderwoude.com
:End
page last modified: 2024-04-16; loaded in 0.0046 seconds