Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Is it possible to code a batch file that will wait in the background or something like that, and when a usb is plugged in, it uploads data onto that usb??

Yeah probably, unless by "wait in the background" you mean "hide while waiting," in which case, probably not.

I understand the "proper" way to do it is not to have a running batch file that sits and waits, but to use a removable drive insertion handler (or whatever its proper name is) that automatically runs your batch file (or any other program) whenever the USB drive is plugged in.
I'm not sure of the details - you'll have to google for them yourself. But what I mean is, when you insert your USB drive, you often get a dialog box asking what you want to do: launch Explorer, download pictures, copy files, or nothing? Well, in that dialog box you can register your own application (probably through the Registry, but not sure how.) The advantage of that is you don't have a batch file running all the time when you don't need it, eating up memory and CPU time, but instead you have it run exactly when you want it to.

If you have a U3 flash drive, you could use an autorun.inf file to call your script.
"Computer security." — Oxymoron

Tony: Good suggestion. I hate U3 drives or any other kind of smart drive, but fortunately I think the autorun.inf should work on ordinary drives too.

It's not too bad... I use a tool to move my digital photos when I mount my memory card or direct attach a camera (that mounts as a disk drive) called DIM - Digital Image Mover. Here are the instructions to do just what you ask, but for his application.. just substitute your batch file for his app:
http://www.alanlight.com/dim/DIMAut...

An autorun.inf is more portable than having to install software to get it to work. I'd go that route, but that's just me.
"Computer security." — Oxymoron

I don't know. Autorun.inf might be only slightly more portable. Autorun on USB is disabled by default on Win2K down, and WinXP/Vista will ask you if you want to run the autorun.inf.

maybe you could use this, I'm not saying it's a good solution but have worked every time I've had to use such a program;
echo off
color a
:1
cls
if exist F: (
start F:
cls
exit
)
goto 1
because then it'll check if the F: drive exists over and over again untill it does!
And then you could compile it to an executable as a ghost app.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |