I needed to copy one file into all of the user directories on computers. I ended up creating a for loop, print it, then use that list as a variable to throw in, worked great. This was one of the few things I could not find on google, so hopefully this hits a few keywords for people when they’re searching. IT IS POSSIBLE! This can be done in BAT, CMD, OR just dump it into a command pronpt changing your own directories/variables as needed.
REM this prints all users in C:\Users\ and then copies the EssUser.cfg file to the PartsDoc Dir
FOR /D %%G IN (c:\Users\*.*) DO xcopy /Y /H /R "E:\PartsDoc Updates\EssUser.cfg" "%%G\Documents\CLAAS\PartsDoc\"
2 replies on “copy a file into all user directories via bat files for windows 7 or xp using a wildcard”
Will this script work in windows 10 ltsc?
I am not sure actually. My preference would be to use robocopy now. I use something very similar to this to back up:
robocopy E:\ \\192.168.50.30\backup\ /E /XD “System Volume Information” “$RECYCLE.BIN” “found.00*” /MIR
Where 192.168.50.30 is my back up server (DESTINATION) and E: is my SOURCE directory.