Wednesday, June 10, 2009

Mass file copy

Recently I needed to copy a shortcut to a mass number of users. Since we utilize Citrix this made the task considerably easier for me. We redirect all user settings to a central location so I was able to easily script out the copy using a Text file that contained the names and Loop through all the user names.

Created the shortcut to be copied and the text file in the following format:

Dim fREM, fLOC, answer, cUser
Const ForReading = 1
Set FSO = Wscript.CreateObject("Scripting.FileSystemObject")
answer = MsgBox("Run the file copy?", 1)
If answer = 2 Then
msgbox "You pressed cancel"
Set objTextFile = FSO.OpenTextFile("c:\ShortcutCopy\names.txt", ForReading)
i = 0
Do Until objTextFile.AtEndOfStream
strNextLine = objTextFile.Readline
cUSER = Split(strNextLine , ",")
fLOC = "C:\ShortcutCopy\ShortcutName.lnk"
fREM = "\\path\path\path\" & cUSER(i) & "\path\desktop\ShortcutName.lnk"
msgbox "Copying to " & fREM
FSO.CopyFile fLOC , fREM, True
i = i + 1
Loop While i<20
msgbox "Copy completed"
End If

No comments:

Post a Comment