Solved

.BAT file that copies file to C:\ drive from CD-Rom

Posted on 2006-10-30
10
3,578 Views
Last Modified: 2008-01-09
Hey Experts,

I am trying to create a bat file. The goal is, when a user pops in a CD, the Autorun file will run the setup program and a BAT file that will copy a file from the CD-Rom to the C:\ drive.

How could I could code? Can a bat file copy a file from a static location to a static location on a hard drive?

IE. Run.bat executed
Copies D:\VPN Client Settings.rcf to C:\ drive

Please help!
0
Comment
Question by:pstiffsae
  • 2
  • 2
  • 2
  • +3
10 Comments
 
LVL 9

Accepted Solution

by:
smidgie82 earned 400 total points
ID: 17835294
Hi pstiffsae,

Sure thing, easy as pie.
run.bat:

copy "D:\VPN client Settings.rcf" c:\



Or, if you want to copy a directory tree, use XCopy:

xcopy "D:\VPN Client Settings\" "c:\VPN Client Settings" /S /E

Run xcopy /?  for the available options



Cheers!
0
 

Author Comment

by:pstiffsae
ID: 17835393
Wahoo! Works like a charm!

Can you run an autorun from a CD-Rom and will it run a bat file with a setup.exe file? (one after another?)
0
 
LVL 9

Assisted Solution

by:smidgie82
smidgie82 earned 400 total points
ID: 17835406
Just put an autorun.inf file on the CD formatted according to the directions at http://autorun.moonvalley.com/autoruninf.htm .  Instead of "open=autorun.exe", use "open=run.bat", and it should go.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 4

Expert Comment

by:chhokra_expert
ID: 17835452
i don't think this can be done using just a bat file. Since you seem to want to do some extra stuff when a CD is inserted, i think you may need to trap the corresponding event notification using a windows service. And as part of this service action then, you can copy over the file. Check out http://www.codeproject.com/useritems/Windows_Services.asp for example on how to write a service.


HTH!
Kumar
0
 
LVL 4

Expert Comment

by:chhokra_expert
ID: 17835460
ok looks like i misuderstood your question... nevermind
0
 
LVL 30

Assisted Solution

by:callrs
callrs earned 50 total points
ID: 17835508
Using D:\ means the command will fail if the CD Drive is some other letter. Try something like:

copy ".\VPN client Settings.rcf" c:\

Which means copy the file from the current folder to c:\
0
 

Author Comment

by:pstiffsae
ID: 17835549
This is what I got:

[autorun]
open= D:\Run.bat
open= D:\setup.exe

It just runs the Bat file and not the setup too. How can I run the setup after the bat or at the same time.

Please help!
0
 
LVL 30

Expert Comment

by:callrs
ID: 17835586
put this line at the end of the bat file:

d:\setup.exe
0
 
LVL 95

Assisted Solution

by:Lee W, MVP
Lee W, MVP earned 25 total points
ID: 17835644
Use one open= line and put setup.exe at the end of the batch file.
0
 
LVL 2

Assisted Solution

by:altra22
altra22 earned 25 total points
ID: 17836994
try shellexecute=setup.exe in secound line
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now