Link to home
Start Free TrialLog in
Avatar of Sanjay
SanjayFlag for United States of America

asked on

batch file operation to copy an access database from the server to the user's desktop

Hi:
I am new to all this but I need help with batch scripting in a  Windows XP or Windows 7 environment

If the user logs offs or switches user then:

1.  All instances of msacess.exe is terminated (i.e. all running versions of ms access databases are killed)
2.  Then when the user logs back in (regardless of who the user is....I am assuming putting some autoexecutable file in the "All Users" folder):
      copy the "Service Database_2000.mdb" database file from the location \\zlv010\mfg_test  TO   the user's desktop without any acknowledgment (automatically occurs in the background with no user intervention)
 
Avatar of setasoujiro
setasoujiro
Flag of Belgium image

ok try this:

@echo off
net use x: /delete
net use x \\zlv010\mfgtest
pause 15
copy x:\service_database_2000.mdb c:\documentsandsettings\%username%\desktop

put this in the startupfolder in the xp machine for all users.
or put in registry under run key.

I do however wonder how they will get the file back to the server?
wouldn't it be easier to just create a shortcut to the file using a script once?
Avatar of Danny Child
I think you may need to be careful with just Killing the msaccess.exe as you may leave Lock files in place on your database (LDB files) which may then prevent others accessing the data.  

And will this lead to multiple versions of your database existing in different locations?  If so, what defines which one is the "right" one?  

Perhaps if you could expand on the problem you are facing, then this would allow us to offer alternate solutions?
Avatar of Sanjay

ASKER

I am trying to update the user's access database desktop copies automatically because I make changes to the master copy and then post it on the network.  Then I have to go around telling multiple users to copy over from the network and this becomes laborious.  The question is, if the user copies the database from the network drive while their desktop copy is open, will this "corrupt" their desktop copy?  If it will, then I need to shut down msaccess and then copy over.  

Also, I do not want to delete the network database file as suggested by setasoujiro.
ASKER CERTIFIED SOLUTION
Avatar of setasoujiro
setasoujiro
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of xylog
xylog

Why not use access's built-in replication?

http://office.microsoft.com/en-us/access-help/CH006252685.aspx