itgremlin Posted February 2, 2009 Posted February 2, 2009 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 profilesi 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\STARTUPis this correct or am i barking up the wrong tree also need to know how to overwrite the file if its already there.thanksGremlin
submix8c Posted February 2, 2009 Posted February 2, 2009 (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. Edited February 2, 2009 by submix8c
Yzöwl Posted February 2, 2009 Posted February 2, 2009 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now