We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you a podcast all about Citrix Workspace, moving to the cloud, and analytics & intelligence. Episode 2 coming soon!Listen Now


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

Patrick asked
Medium Priority
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!
Watch Question

Hi pstiffsae,

Sure thing, easy as pie.

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


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


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?)
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.
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.

ok looks like i misuderstood your question... nevermind
Awarded 2006
Top Expert 2006
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:\


This is what I got:

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!
Awarded 2006
Top Expert 2006

put this line at the end of the bat file:

Lee W, MVPTechnology and Business Process Advisor
Most Valuable Expert 2013
Use one open= line and put setup.exe at the end of the batch file.
try shellexecute=setup.exe in secound line
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.