China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

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!

中国DOS联盟论坛
The time now is 2026-06-26 14:20
中国DOS联盟论坛 » 其它操作系统综合讨论区 » Seeking help: method to safely delete USB flash drive using pure script View 2,719 Replies 8
Original Poster Posted 2007-10-31 05:58 ·  美国
初级用户
Credits 146
Posts 14
Joined 2004-04-23 00:00
22-year member
UID 23108
Gender Male
Status Offline
Given that the U disk drive letter is I:, is it possible to safely delete the U disk using a pure script (without adding any other executable files)?
Floor 2 Posted 2007-11-04 23:51 ·  美国
初级用户
Credits 146
Posts 14
Joined 2004-04-23 00:00
22-year member
UID 23108
Gender Male
Status Offline
Is really no one will? Can't even use.vbs or.js?
Floor 3 Posted 2007-11-05 00:10 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
Knowing the parameters of rundll32.exe that can pop up the safe removal dialog is simple
第一高手 第二高手

Floor 4 Posted 2007-11-05 00:38 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
Credits 5,493
Posts 2,315
Joined 2006-05-01 10:41
20-year member
UID 54766
Gender Male
From 上海
Status Offline
VBS

set ws=wscript.createobject("wscript.shell")
ws.run "rundll32.exe shell32.dll,Control_RunDLL hotplug.dll"
wscript.sleep 2000
ws.sendkeys("{tab 2}")
wscript.sleep 200
ws.sendkeys("%s")
wscript.sleep 200
ws.sendkeys("{enter}")
wscript.sleep 2000
MsgBox "Device has been ejected!" ,64+vbOKOnly
ws.sendkeys("%{f4}")
Recent Ratings for This Post ( 1 in total) Click for details
RaterScoreTime
zhangwencheng +1 2009-05-13 01:34
第一高手 第二高手

Floor 5 Posted 2007-11-05 17:08 ·  中国 上海 松江区 电信
铂金会员
★★★★
DOS一根葱
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 ]
第一高手 第二高手

Floor 6 Posted 2007-12-20 05:26 ·  美国
初级用户
Credits 146
Posts 14
Joined 2004-04-23 00:00
22-year member
UID 23108
Gender Male
Status Offline
Thanks to fastslz, I've learned a lot
Floor 7 Posted 2008-04-23 14:17 ·  中国 浙江 杭州 电信
初级用户
Credits 55
Posts 28
Joined 2007-12-24 11:57
18-year member
UID 106624
Gender Male
Status Offline
Very good. Give a thumbs up.
Floor 8 Posted 2008-05-08 11:07 ·  中国 天津 联通
初级用户
Credits 34
Posts 20
Joined 2006-10-15 08:57
19-year member
UID 65839
Status Offline
Learning, learning, so amazing!
Floor 9 Posted 2009-04-08 04:33 ·  中国 广东 珠海 电信
新手上路
Credits 3
Posts 2
Joined 2009-03-19 06:26
17-year member
UID 141730
Gender Male
Status Offline
A big thumbs up for fastslz!
Forum Jump: