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, select manage, go services,
    select windows driver foundation - user-mode driver framework , make sure it's running , startup type set automatic or automatic (delayed start).

now go task scheduler:

  1. make new task, name mycoolbatch on usb-connect.
  2. on triggers tab add new trigger:

    • on event in first dropdown box
    • microsoft-windows-driverframeworks-usermode/operational in log dropdown
    • driverframeworks-usermode in source
    • 2003 in event id (this usb connect event)

    new trigger screenshot

  3. on actions tab make new action , select batch file.
    can add parameter plugged.

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

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -