Jump to content

Recommended Posts

Posted

Please can someone help me with writting a batch file.

i need to copy a file to a folder within the each users profile on a computer some computers have multiple profiles

i have the start of the batch file am i getting this right ?

xcopy L:\pil97.doc C:\Documents and Settings\%userprofile%\Application Data\Microsoft\Word\STARTUP

is this correct or am i barking up the wrong tree also need to know how to overwrite the file if its already there.

thanks

Gremlin


Posted (edited)

Uh, try opening a Command Prompt and running "xcopy /?"...

No offense, but the Help functions of programs "helps"...

Also, the variable provided is only good for the profile of the logged-on User-ID (you stated multiple profiles). The batch CMD file would have to get all user-id's from Documents And Settings as-you-go to get it copied in one shot...

edit - I see a couple of smart lurkers in here - they may be able to provide you with an exact CMD file. :P

Edited by submix8c
Posted

First things first, you're copying a single file with no parameters therefore xcopy is not necessary, a simple copy will do you.

Try something like this!

@Echo off&Setlocal enableextensions&Pushd %UserProfile%\..
Set "£=L:\pil97.doc"&Set "_=Application Data\Microsoft\Word\STARTUP"
For /f "delims=" %%# In ('Dir/b/ad-h') Do If Exist "%%#\%_%" (
If Not Exist "%%#\%_%\%£:*\=%" Copy %£% "%%#\%_%")

Due to your paths it is assumed that you're using XP, this will not work in Vista or Newer.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...