Script to Copy Folder and Sub-Folders and Files To All Users

Hello Experts,

I am wondering if there is a easy way to copy folders and sub-folders to all user accounts in Windows XP except Administrator, Default User, All Users, LocalService, NetworkService.

I have users that share computers that I need to copy a set of files via folder.

The contents is located in C:\_CONTENT
The sub-folders are C:\CONTENT\WEBFORMS & C:\CONTENT\SALESFORMS

I know I can copy to all user accounts by using the Default User account but I would like to not copy Administrator, Default User, All Users, LocalService, NetworkService accounts.

Can someone help me I do not really know how to program.
LVL 1
katredrumAsked:
Who is Participating?
 
Shift-3Connect With a Mentor Commented:
Correction.


@echo off
setlocal
 
set source=C:\_CONTENT
set dest=My Documents\CONTENT
set filter=/C:"All Users" /C:"Default User" /C:"LocalService" /C:"NetworkService"
 
for /F "tokens=*" %%G in ('dir "%allusersprofile%\.." /A:D /B^| findstr /I /V %filter%') do (
 ECHO xcopy "%source%\*.*" "%allusersprofile%\..\%%G\%dest%\" /E /C /H /R /Y
)
 
pause

Open in new window

0
 
Raheem05Commented:
Katredrum,

Are these users domain users? Would if not be easier setting a share and giving them rights to this share as a mapped drive?

Unless a program needs these files to run locally?
0
 
Bill PrewCommented:
Where in each users files do you want the copied in files to reside?  Meaning do you want:

c:\_content -> c:\documents and settings\user1\_content

Or do you want it in their My Documents?  Do you actually want the _content directory, or just the 2 subfolders in each user?

~bp
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
johnb6767Commented:
Or, at minimum, just give them a Desktop shortcut if you dont want to put it on the network as a share.....
0
 
Shift-3Commented:
As others have pointed out, it would make more sense to use a network share or copy the files under the All Users profile.  However, if you really wanted to copy them under each individual user's profile, here is a way.

Paste the script below into a text file with a .cmd extension.  Customize the value of the dest variable on line 5 with the location under each user's profile to copy the files to.  Running the script will echo the commands to be run.  Once you have tested it successfully and are certain it will do what you intend, remove the word ECHO from line 9 to copy the files.  Any existing files will be overwritten.


@echo off
setlocal
 
set source=C:\_CONTENT
set dest=My Documents\CONTENT
set filter=/C:"All Users" /C:"Default User" /C:"LocalService" /C:"NetworkService"
 
for /F "tokens=*" %%G in ('dir "%allusersprofile%\.." /A:D /B^| findstr /I /V %filter%') do (
 ECHO xcopy "%source%\*.*" "%allusersprofile%\..\%%G\%dest%\" C /H /R /Y
)
 
pause

Open in new window

0
 
johnb6767Commented:
Reason for the Network Share/Desktop Shortcut, is that you dont want multiple copies of files all over user profiles. You need 1 folder with the files, and all users should only POINT to it, so there is a single spot for storage....
0
 
katredrumAuthor Commented:
Thanks everyone who replied. I know having multiple files for each profile is not good practice but we are trying to keep brand new files for everyone that logs in to eliminate any unequal opportunity. I will try the script and will let you know.
0
 
katredrumAuthor Commented:
Perfecto! Thank you very much!
0
All Courses

From novice to tech pro — start learning today.