copy_a_folder_to_all_user_profiles_on_pc.vbs

This script will copy a folder and its contents to every user profile on a pc
It excludes the public, default, and administrator accounts
Enter the list of computers you wish to apply it to in the computerslist.txt file with one computer per line.

Source Code

This script has not been checked by Spiceworks. Please understand the risks before using it.

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

'this script will copy a folder and its contents to every user profile on a pc 'it excludes the public, default, and administrator accounts'enter the list of computers you wish to apply it to in computerslist.txtdimobjShelldimobjFoldersetobjShell=CreateObject("Shell.Application")ConstForReading=1ConstOverwriteExisting=TRUE'On Error Resume NextSetobjFSO=CreateObject("Scripting.FileSystemObject")'Change location and name of computers to copy to belowSetobjFile=objFSO.OpenTextFile("C:\computerslist.txt")'change path to "\C$\documents and settings\" for xpdocPath="\C$\users\"'read each computer name from text fileDoUntilobjFile.AtEndOfStreamstrComputer=objFile.ReadLine'navigate to the Documents and Settings folder to get userssetobjFolder=objShell.NameSpace("\\"&strComputer&docPath)'loop through users and copy folder to location specified belowforeachxinobjFolder.items'skip certain user profiles specified belowifx<>"Default"Andx<>"Administrator"Andx<>"Public"Then'msgbox "\\" & strComputer & docPath & x & "\AppData\Local\Microsoft\Office"'change folder name below to the folder you want to copy to on each profilestrRemoteFolder="\\"&strComputer&docPath&x&"\location to copy to\"'change folder name below to the folder you want to copy to on each profile. this folder gets copied to the folder you specified aboveobjFSO.CopyFolder"C:\copyfolder",strRemoteFolder,OverwriteExistingEndIfNextLoop'close the fileobjFile.close