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.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Recently Browsing   0 members

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