Accepting input to BAT file by dragging.

  • Thread starter Thread starter GO
  • Start date Start date
G

GO

Remove the quotes from the command line argument (ie %1). You are in affect
wrapping your variable in two sets of quotes which the system does not
understand. Another problem you are going to run into is that you will
only be able to copy one file at a time; if you try to copy multiple
(selected) files, each file would be a seperate argument (ie %1, %2, %3,
etc). I'm not sure how you'll be able to get around this issue.
 
How do I create a shortcut to a BAT file that will accept a file dragged
onto it.
I created a simple bat file "copyto.bat" which didn't work (containing):

@echo off
copy "%1" c:\xfer
copy "%1" c:\saves
exit

I then created a shortcut to it and modified the shortcut properties to
be:
C:\WINDOWS\Desktop\copyto.bat "%1"

When I drag a file onto the shortcut, it doesn't do the copy.
Does anyone have any suggestions or another way to do this?
(Win 2000 or XP)

Thanks.
 
Did you remove the modifications to the shortcut properties that you had
made earlier? A command prompt window should open regardless though, so I'm
not sure what to recommend at this point. What happens if you just
double-click on the batch file itself? Does a command window open at that
point? If not, the file association with batch files may be broken.
 
Tried your suggestion of removing the quotes in the command shortcut.
Still nothing. Tried putting a pause command before the exit in the bat
file. No window opens or anything.
 
nospam said:
I created a simple bat file "copyto.bat" which didn't work (containing):
@echo off
copy "%1" c:\xfer
copy "%1" c:\saves
exit
I then created a shortcut to it and modified the shortcut properties to
be:
C:\WINDOWS\Desktop\copyto.bat "%1"

Try removing the "%1" from the shortcut. Having the name of the batch
file alone works for me.

When testing a new batch file, it's always a good idea to leave echo on
and put a pause command at the end. It's much easier to tell what's
happening that way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top