Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CHECK STATUS and RESTART of USB Device
REM This Script Need the devcon.exe (Include Microsoft WDK)
echo off
setlocal
REM Make Tempfile PATH
set TMP_FILE=%~dp0tmp_status.log
REM Define USB Device ID
set USB_DEV_ID="USB\VID_0590&PID_0081&REV_0109"
REM Run the Get STATUS of USB Device
%windir%\devcon.exe status %USB_DEV_ID% > %TMP_FILE%
REM Check STATUS. and Excec RESTART
find /i "Driver is running." %TMP_FILE% > nul
if not %ERRORLEVEL% equ 0 (
%windir%\devcon.exe restart %USB_DEV_ID% > %TMP_FILE%
if exist %TMP_FILE% ( del %TMP_FILE% )
exit /b 1
)
if exist %TMP_FILE% ( del %TMP_FILE% )
endlocal
exit /b 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.