Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3593
  • Last Modified:

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

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
pstiffsae
Asked:
pstiffsae
  • 2
  • 2
  • 2
  • +3
5 Solutions
 
smidgie82Commented:
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
 
pstiffsaeAuthor Commented:
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
 
smidgie82Commented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
chhokra_expertCommented:
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
 
chhokra_expertCommented:
ok looks like i misuderstood your question... nevermind
0
 
callrsCommented:
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
 
pstiffsaeAuthor Commented:
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
 
callrsCommented:
put this line at the end of the bat file:

d:\setup.exe
0
 
Lee W, MVPTechnology and Business Process AdvisorCommented:
Use one open= line and put setup.exe at the end of the batch file.
0
 
altra22Commented:
try shellexecute=setup.exe in secound line
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now