Link to home
Start Free TrialLog in
Avatar of katredrum
katredrumFlag for United States of America

asked on

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.
Avatar of Raheem05
Raheem05
Flag of United Kingdom of Great Britain and Northern Ireland image

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?
Avatar of Bill Prew
Bill Prew

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
Or, at minimum, just give them a Desktop shortcut if you dont want to put it on the network as a share.....
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

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....
ASKER CERTIFIED SOLUTION
Avatar of Shift-3
Shift-3
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of katredrum

ASKER

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.
Perfecto! Thank you very much!