Dim WshNet, WshShell, wshNetwork
set WshShell = CreateObject("WScript.shell")
Set wshNetwork = CreateObject("WScript.Network")
On Error Resume Next
Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
'Change objPath to reflect profile location
'Dim objpath : objpath = "c:\src\" & wshNetwork.UserName
Dim objpath : objpath = "\\SERVERNAME\profiles$\" & wshNetwork.UserName
'Dim objStartFolder : objStartFolder = "C:\src\" & wshNetwork.UserName & ".v2"
Dim objStartFolder : objStartFolder = objpath & ".v2"
Dim objV6Folder : objV6Folder = objpath & ".v6"
'Dim objDestFolder : objDestFolder = "C:\src\" & wshNetwork.UserName & ".v6"
'Change objDestFolder when going live
Dim objDestFolder : objDestFolder = "C:\Users\" & wshNetwork.UserName
Dim objControlFile : objControlFile = objDestFolder & "\profile.txt"
Dim objFolder : Set objFolder = objFSO.GetFolder(objStartFolder)
Dim strDestPath : objDestFolder
Dim Subfolder
Dim colFiles
Dim objFile
Dim oFolder, coFiles
Dim ValidFolder
' Exit if base folder does not exist
If Not objFSO.FolderExists(objStartFolder) Then
'Wscript.Echo "Missing base folder : """ & objStartFolder & """"
Wscript.Quit
End If
' Exit if base folder does not exist
If Not objFSO.FolderExists(objV6Folder) Then
'Wscript.Echo "Missing Destination folder : """ & objDestFolder & """"
Wscript.Quit
End If
' Exit if base folder does not exist
If objFSO.FileExists(objControlFile) Then
'Wscript.Echo "Profile already updated"
Wscript.Quit
End If
'wScript.Echo "The Starting Profile path is: " & objStartFolder
Call CopyScottFolders (objFSO.GetFolder(objStartFolder), objDestFolder)
Set objFile = objFSO.CreateTextFile(objControlFile)
'wScript.Echo "Profile Update Complete"
Set WshNet = Nothing
Set WshShell = Nothing
Sub CopyScottFolders(Folder, strDestPath)
For Each Subfolder in Folder.SubFolders
If SubFolder.Name <> "Saved Games" and SubFolder.Name <> "Searches" and SubFolder.Name <> "Windows" <> "TaskBar" Then
Set oFolder = objFSO.GetFolder(Subfolder.Path)
Set coFiles = oFolder.Files
'Wscript.echo "Copying folder: " & oFolder.Name
If Not objFSO.FolderExists(strDestPath & "\" & oFolder.Name) Then
'Wscript.echo "Creating Folder:" & strDestPath & "\" & oFolder.Name
objFSO.CreateFolder(strDestPath & "\" & oFolder.Name)
End if
For Each objFile in coFiles
If not instr(objFile.path,"ntuser") Then
'Wscript.echo "Copying From:" & objFile.path
'Wscript.echo "Copying To:" & strDestPath & "\" & oFolder.Name & "\" & objfile.Name
objFSO.CopyFile objFile.Path, StrDestPath & "\" & oFolder.Name & "\" & objfile.Name
End If
Next
End If
Call CopyScottFolders (Subfolder, StrDestPath & "\" & oFolder.Name)
Next
End Sub