Custom Search
Join the PC homebuilding revolution! Read the all-new, FREE 200-page online guide: How to Build Your Own PC!
NOTE: Using robot software to mass-download the site degrades the server and is prohibited. See here for more.
Find The PC Guide helpful? Please consider a donation to The PC Guide Tip Jar. Visa/MC/Paypal accepted.
Page 2 of 2 FirstFirst 12
Results 26 to 31 of 31

Thread: Automatically run a batch file on USB device insertion/removal

  1. #26
    Join Date
    Oct 2001
    Location
    N of the S of Ireland
    Posts
    20,504
    and put the description there like the file need to be executed when pen drive inserted
    I think you have missed the point that the problem actually is more complex since not all USB devices are pen drives - or even drives at all. This program is designed to identify and to react to USB devices of all sorts on both insertion and/or removal.

    In addition autorunning may well be disabled by the OS in question.
    Take nice care of yourselves - Paul - ♪ -
    Help to start using BiNG. Some stuff about Boot CDs & Data Recovery Basics & Back-up using Knoppix.

  2. #27
    Hey Paul,
    I downloaded your program because i think its pretty amazing, but unfortunately i havent been able to get it working properly. After booting up the program, it doesnt seem to recognize any USB device that is inserted or removed from the computer. Im running a windows 7, 64 bit. Does this program only work for Windows XP or am i just missing something?

    Thanks!

  3. #28
    Join Date
    Nov 2000
    Location
    The Mountain State
    Posts
    23,389
    Try running it as administrator...
    AV, Anti-Trojan List;Browser and Email client List;Popup Killer List;Portable Apps
    “When men yield up the privilege of thinking, the last shadow of liberty quits the horizon.” - Thomas Paine
    Remember: Amateurs built the ark; professionals built the Titantic."

  4. #29
    One of the first things I tried. Its a no go..

  5. #30
    Join Date
    Oct 2001
    Location
    N of the S of Ireland
    Posts
    20,504
    I have had other reports of it not functioning under Win 7. Unfortunately I don't have time a the moment to attempt to upgrade it. Have you tried compatibility mode for XP?
    Take nice care of yourselves - Paul - ♪ -
    Help to start using BiNG. Some stuff about Boot CDs & Data Recovery Basics & Back-up using Knoppix.

  6. #31

    Post

    Hi everyone,

    I'm new around here but have the same issue.

    I wrote something in a little batch file that gets the job done. In a nutshell it's a batch file which runs every few seconds and calls devcon to see if a device with a particular device ID is attached. It can run something different when the device is inserted as well as removed.

    I wrote this to detect whether my laptop is plugged into my USB docking station so it refers to docking all the way through - but it will work with whatever device you want. In my case I wanted it to switch power plans and turn off my wireless, but you could have it do anything you want.

    List of files and description:
    • dock.cmd - This cmd file does the actual executing of the specified commands
    • dock_success.vbs - Successful dock message box
    • poll.cmd - Polls the system for the given device ID and call dock.cmd if the device has been added or removed since the last check
    • silent.vbs - Calls poll.cmd silently
    • undock_success.vbs - Successful undock message box
    • undocked.txt - File to tell the script whether the system is docked or not (will change to docked.txt when docked)


    Notes:
    • I have tested this with Windows 7 x64 and it works flawlessly.
    • I suggest you add 'silent.vbs' to your Startup folder on the Start menu so it runs when you log on.
    • The files need to be extracted to 'c:\dock' - this could be changed in the code without too much work though.
    • The 'undocked.txt' file needs to exist before you run the script the first time.
    • You will need a copy of 'devcon.exe' from Microsoft. I have tested with the 64 bit version on Win7 x64 and it works flawlessly.


    Feel free to change anything in the scripts and redistribute
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •