usb drive - Autorun batch file through eject command -
is possible batch script on local machine (e.g. in d:\ batch files\1.bat
) run after insert or eject usb drive?
preliminaries:
- right-click
computer
icon, selectmanage
, goservices
,
selectwindows driver foundation - user-mode driver framework
, make sure it's running , startup type setautomatic
orautomatic (delayed start)
.
now go task scheduler
:
- make new task, name
mycoolbatch on usb-connect
. on
triggers
tab add new trigger:on event
in first dropdown boxmicrosoft-windows-driverframeworks-usermode/operational
in log dropdowndriverframeworks-usermode
in source2003
in event id (this usb connect event)
on
actions
tab make new action , select batch file.
can add parameterplugged
.
repeat steps 1-3 event id 2100
(the usb disconnect event) , batch file parameter ejected
so, assuming same batch file used, can check if device connected/ejected:
if "%1"=="plugged" ......... if "%1"=="ejected" .........
based on the windows 7 event log , usb device tracking article.
Comments
Post a Comment