Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2010-09-13
7
Medium Priority
?
644 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 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1000 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 1000 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
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 120

Expert Comment

by:Rey Obrero (Capricorn1)
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

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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

886 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