Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!
Credits 5,493 Posts 2,315 Joined 2006-05-01 10:41 20-year member UID 54766 Gender Male From 上海
Status Offline
Hehe...Let's have another more rogue one...Using the Microsoft command line extension tool DevCon.exe
@echo off
devcon.exe>nul 2>nul
if %errorlevel%==9009 (CLS&&echo.&&COLOR 0E&&echo This script requires the Microsoft DevCon.exe command-line utility support&&ping/n 5 127.1>nul&&exit/b)
for /f "tokens=1,2 delims=\" %%i in ('devcon find usb\*^|find /i "Mass Storage"') do set "USBHDID=%%i\%%j"
if "%USBHDID%"=="" color 0b&cls&echo.&echo USB disk device not found!&ping/n 5 127.0.1>nul&exit
color 0e&cls&echo.&echo Disabling your USB disk device...
for /f "tokens=1,2 delims=\" %%i in ('devcon find usb\*^|find /i "Mass Storage"') do devcon.exe disable "%%i\%%j" >nul 2>nul
color 0b&cls&echo.&echo USB disk device has been disabled!&ping/n 3 127.0.1>nul
color 0a&cls&echo.&echo Press any key to enable your USB disk device...&pause>nul
for /f "tokens=1,2 delims=\" %%i in ('devcon find usb\*^|find /i "Mass Storage"') do devcon.exe enable "%%i\%%j" >nul 2>nul
color 0e&cls&echo.&echo All OK!Waiting to exit...&ping/n 4 127.0.1>nul
[ Last edited by fastslz on 2008-1-16 at 02:47 PM ]