Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Automatically copy database from CD to Hard Drive

Status
Not open for further replies.

phillib5

Programmer
Mar 2, 2005
13
US
Does anyone know a way to automatically copy a database file from CD to a hard drive? And then have the database open up automatically from the HD?

I understand a batch file could be used to do so, however I'm not sure on the commands.

Any help is much appreciated, thank you!

-Bryant
 
I IMAGINE you would have to create a new DBase to initiate the commands.

you can set up a Start-Up form, from Form_load event, run the procedures.
or use AutoExec macro.

Windows has a task scheduler to initiate events at a certain time.

FileCopy "D:\Access.mdb", "C:\Documents And Settings\Bryant\My Documents\Access.mdb"

Dim App, File, x As Integer
'works
App = Chr(34) & "C:\Program Files\Microsoft Office\OFFICE11\Msaccess.exe" & Chr(34)
File = Chr(34) & "C:\Documents And Settings\Bryant\My Documents\Access.mdb"
& Chr(34)

'x = Shell("""" & App & """" & " " & """" & "" & File & """", 2)
x = Shell(App & " " & File, 2)
 
This is a start. Try doing a search with "Batch File" most everything you could dream of will be returned.

rem Please don't remove this file or the .bat file that is located in the same folder
rem Update to Reported DB for 2005

copy "d:\IFTA02-05.lnk" "c:\documents and settings\all users\desktop\ifta02-05.lnk"

del "c:\documents and settings\all users\desktop\ifta01-04.lnk"

copy "d:\IFTA02-05.mdb" "c:\My Documents\IFTA02-05.mdb"

start C:\My Documents\IFTA02-05.mdb

end
 
Here is a simple bat file that will copy and open the file.
Code:
REM copy /Y - Overwrite existing file w/o prompt
copy /Y D:\test.mdb C:\
start C:\test.mdb
cls

paste code into notepad, choose save as...
Make sure file type is set to all files, then name it with a .bat extension

FYI...
The mdb will most likely be read-only... even after it is copied to the harddrive, due to it's orginal location was CD. Attributes get changed after it's burned to CD

If you need to change the attributes, do a search for or post a thread.

Carl



AccessGuruCarl
Programmers helping programmers
you can't find a better site.
 
Hi phillib5,

Here is an updated code...
It will change the attributes as well..

Code:
REM copy /Y - Overwrite existing copy w/o prompt
copy /Y D:\test.mdb C:\
REM Remove Read-Only Attribute
attrib -r C:\test.mdb
start C:\test.mdb
cls

Carl

AccessGuruCarl
Programmers helping programmers
you can't find a better site.
 
Thanks guys. Carl, I was able to use your code in a batch file and it does just what I need.

Now, I'm trying to find out how to refer to the current CD drive in use instead of D: when the database gets copied.

Thanks again.
 
I think I got it - %CD% in place of D:\ works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top