Solved

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

Posted on 2010-09-13
7
626 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 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
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

828 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