VBS Script to copy files with permissions
Posted on 2008-10-28
One of our techs was pointing a bunch of users to their home directory in Active Directory by highlighting all users, and using the variable %username% at the end. Unfortunately, they accdidentally left a "j" infront of the %username%. So now every user has a j infront of their home folder name. I dumped a list of all users home directorys, and wrote a script to check for the j, then copy the contents from the folder with the j, to the folder without the j.
Everything works fine, except its not copying over the folder/file permissions. I can't seem to find an option to do that with the method I am using. I have also looked into using robocopy.exe from the resource kit, but had some issues. I think my script is much simpler, if I could only get it to copy permissions.
Here is my script:
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile ("c:\scripts\users.txt", 1)
Set objShell = CreateObject("Wscript.Shell")
Do Until objTextFile.AtEndOfStream
strHD = objTextFile.Readline
If objFSO.FolderExists("c:\scripts\users\j"+strHD) then
set copyHD = objFSO.GetFolder("c:\scripts\users\j"+strHD)
If anyone has any ideas that wold be great!