Solved

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

Posted on 2010-09-13
7
628 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

752 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