Question : batch file to copy database to user specific directory

Hi All,

I am new to creating batch files and never been a dos user so I'm stuggling a little.

I am looking to create the easiest possible way of deploying a database front end to multiple users.  The front end needs to be housed on the users local machine and they can always download the latest version from a server.

What I would like to do is place a batch file on the server that:

a) creates a directory on the users local machine by collecting their user ID (or skips this if the directory already exists)
b) copies the database from the server
c) pastes it in the newly made directory (or overwrites the existing file)
d) puts a shortcut to the database on the users desktop.

All users are on machines running XP with roaming profiles.

The directory that is created by the batch file needs to be variable based on the users windows ID

So for instance the directory I want to create will always be:
"C:\Documents and Settings\**Windows ID Here***\My Documents\MySystem"

The shortcut will need to go on:
"C:\Documents and Settings\**Same Widnows ID Here**\Desktop\ShortcutName"

So far I have:

1:
2:
3:
4:
5:
6:
@echo off
cls
mkdir C:\Documents and Settings\%username%\My Documents\MySystem

XCOPY G:\Server\SourceFile.mdb  C:\Documents and Settings\%username%\My Documents\MySystem\ /C /S /D /Y /I


Not working becuase the %username% isn't referenced properly.

Can anyone help with this?

Cheers
DeZZar

Answer : batch file to copy database to user specific directory

Seems to me you were real close before, but likely the lack of quotes around any pathnames that contained spaces was causing problems.  SO I think this would work:

@echo off
cls
if not exist "C:\Documents and Settings\%username%\My Documents\MySystem\" mkdir "C:\Documents and Settings\%username%\My Documents\MySystem"
xcopy "G:\Server\SourceFile.mdb" "C:\Documents and Settings\%username%\My Documents\MySystem\" /C /D /Y /I

I removed the /S from the XCOPY, don't think you want that since you are only copying one file.

Also, since you have the /I on the XCOPY, it would create the destination directory if it doesn't exist, so I think this can be further simplified to:

@echo off
cls
xcopy "G:\Server\SourceFile.mdb" "C:\Documents and Settings\%username%\My Documents\MySystem\" /C /D /Y /I

~bp
Random Solutions  
 
programming4us programming4us