Solved

Questions Copying Front End of Access database to users' desktops using MS DOS Batch File.

Posted on 2010-09-13
7
613 Views
Last Modified: 2013-11-28
I have split an Access 2007 database and was given the following code, which is supposed to copy the front end to the user's desktop. Please help me to understand this code, so that I can tweak it to apply it to my situation. The code is as follows:

Echo OFF
IF NOT EXIST "\\xxxxxxfps01\Home\%USERNAME%" GOTO server07
Mkdir "\\xxxxxxfps01\Home\%USERNAME%\Catalog\"
IF EXIST "\\xxxxxxfps01\Home\%USERNAME%\Catalog" DEL "\\xxxxxxfps01\Home\%USERNAME%\Catalog\*.*" /Q
XCOPY "\\xxxxxxfps01\Catalog\Front End\PMCatalog_09132010.mdb" "\\xxxxxxfps01\Home\%USERNAME%\Catalog\" /I
START "Catalog" /MAX "\\xxxxxxfps01\Home\%USERNAME%\Catalog\PMCatalog_09132010.mdb"
Exit
:server07
IF NOT EXIST "\\xxxxxxfps01\Home\%USERNAME%" GOTO server06
Mkdir "\\xxxxxxfps01\Home\%USERNAME%\Catalog\"
IF EXIST "\\xxxxxxfps01\Home\%USERNAME%\Catalog" DEL "\\xxxxxxfps01\Home\%USERNAME%\Catalog\*.*" /Q
XCOPY "\\xxxxxxfps01\Catalog\Front End\PMCatalog_09132010.mdb" "\\xxxxxxfps01\Home\%USERNAME%\Catalog\" /I
START "Catalog" /MAX "\\xxxxxxfps01\Home\%USERNAME%\Catalog\PMCatalog_09132010.mdb"
Exit
:server06
Mkdir "\\xxxxxxfps01\Home\%USERNAME%\Catalog\"
IF EXIST "\\xxxxxxfps01\Home\%USERNAME%\Catalog" DEL "\\xxxxxxfps01\Home\%USERNAME%\Catalog\*.*" /Q
XCOPY "\\xxxxxxfps01\Catalog\Front End\PMCatalog_09132010.mdb" "\\xxxxxxfps01\Home\%USERNAME%\Catalog\" /I
START "Catalog" /MAX "\\xxxxxxfps01\Home\%USERNAME%\Catalog\PMCatalog_09132010.mdb"
Exit

Question 1: \\xxxxxxfps01\Home\%USERNAME%"
Does this path refer to the user's Desktop? xxxxxxfps01 is the server name.

Question 2:
I want the front end to be copied to a folder 'Catalog' on the user's desktop. How is this coded?

Question 3:
I want the .mdb, PMCatalog_09132010.mdb, to reside in a folder 'Catalog' on the G: drive, which is xxxxxxfps01. How is this coded?
0
Comment
Question by:newbie46
  • 3
  • 2
  • 2
7 Comments
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 250 total points
ID: 33668615
to refer to the user Desktop
"C:\Documents and Settings\%username%\desktop\"

'create the Catalog directory on the user desktop

mkdir  "C:\Documents and Settings\%username%\desktop\Catalog"
' copy the front end

copy  "\\xxxxxxfps01\Catalog\Front End\PMCatalog_09132010.mdb" "C:\Documents and Settings\%username%\desktop\Catalog\PMCatalog_09132010.mdb"
0
 
LVL 65

Assisted Solution

by:rockiroads
rockiroads earned 250 total points
ID: 33669278
simple explanation

Echo Off = dont display output
IF NOT EXIST = if directory doesnt exist goto the label server07 and run the code from there
Mkdir = create directory
IF EXIST ... DEL = if file exists then delete
XCOPY = copy
START = run in a seperate window

the sample code has home directories in a different place to normal

you can get to it like cap says or you can use USERPROFILE, this should be set. You can confirm this by typing in SET from the dos command

The above should answer q1

In reality one call should do it as xcopy can create the directory structure if it does not exist

eg   xcopy "C:\temp\a" "%USERPROFILE%\Desktop\Catalog\" /e /y

will copy the contents of folder c:\temp\a to USERPROFILE\Desktop\Catalog
so if userprofile is c:\documents and settings\fred it would equate to

copy contents of c:\temp\a to c:\documents and settings\fred\Desktop\Catalog

I prefer the use of directories as it is then open to copy more files without having to change the code

That should answer q2

and finally q3, well simple replace c:\temp\a with your folder where the mdb resides, no need to specify filenames


0
 

Author Comment

by:newbie46
ID: 33672365
I'm not having any luck, so I'm starting with the basics. I'm trying to get the following statements working.

Echo on
mkdir  "C:\Documents and Settings\kloskoc\Desktop\Catalog"
copy  "C:\Documents and Settings\kloskoc\Desktop\MPPB Database\PMCatalog_09132010.mdb" "C:\Documents and Settings\kloskoc\Desktop\Catalog"
Exit

The black command prompt window comes up quickly and then disappears, but the file is not copied. What could be the problem?

Thanks.



Exit
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 119

Expert Comment

by:Rey Obrero
ID: 33672420
you did not include the file on the destination folder

Echo on
mkdir  "C:\Documents and Settings\kloskoc\Desktop\Catalog"
copy  "C:\Documents and Settings\kloskoc\Desktop\MPPB Database\PMCatalog_09132010.mdb" "C:\Documents and Settings\kloskoc\Desktop\Catalog\PMCatalog_09132010.mdb"
Exit
0
 

Author Comment

by:newbie46
ID: 33673611
I cut and paste the statements from your last comment above into the Batch file. The black command prompt window still comes up quickly and disappears. It is displaying the message,  "The system cannot find the file specified." Is the extension the issue? Removing the extension, it still cannot find the file.
Any ideas?
0
 
LVL 119

Expert Comment

by:Rey Obrero
ID: 33673641
are you sure the file from the Source folder?

"C:\Documents and Settings\kloskoc\Desktop\MPPB Database\PMCatalog_09132010.mdb"
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33674425
where is your original mdb file? is it in the g drive? if so then source file would be from the g drive
remember what I said about xcopy, it creates the directories for you
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

744 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

10 Experts available now in Live!

Get 1:1 Help Now