We are migrating to a new server and totally redesigning how we manage data.
Currently, have a "Home" drive mapped at login. They also have a default cofiguration of "My Documents" containing "My Music" and "My Pictures".
We created a DFS namespace "\\domain\File\Home$" which points to "\\server\D$\~Home". We are also using ABE (Access-based Enumeration) so that users navigating to this share only see their folder. For example, if I navigate to "\\domain\File\Home$", it will only show my folder "stovalld" -> "\\domain\File\Home$\stova
lld".
Next, we want to use a GPO to redirect the user's "My Documents" to their network share - "\\domain\File\Home$\stova
lld\My Documents". That part is easy.
Here's the part we are having trouble with.
We don't want to redirect the hundreds of Gigabytes of "My Music" and "My Pictures" to the new file server. Instead, we want to make certain that those folders are redirected to a location on the local machine ("%USERPROFILE%\MyLocalDat
a\My Music" and "%USERPROFILE%\MyLocalData
\My Pictures"). Once redirected, we will create "MyMusic.lnk" and "MyPictures.lnk" links in the "My Documents" that point to the Music and Picture files (this is done to give the user a familiar reference point to their music and pictures). I already have a script that copies the folders and creates the link files, and it also modifies the registry: HKEY_CURRENT_USER\Software
\Microsoft
\Windows\C
urrentVers
ion\Explor
er\Shell Folders (My Music and My Pictures) to point to the new locations.
Problem - I have to do all of the above (moving/redirecting the My Music and My Pictures to the new location on the local drive) prior to activating the GPO that redirects "My Documents" to the network share on the new file server. Otherwise, when the user logs on and activates the GPO, if the My Music and My Pictures are still residing in the My Documents, it could take a very long time before the users sees his desktop during the first boot up.
Desire - When I activate the GPO that redirects My Documents to the network share, I want it to copy only the documents in My Documents so that initial synchronization only takes a few seconds. If My Music and My Pictures are still a part of My Documents, it could take the better part of an hour for the intial boot and synchronization - plus we would have a whole bunch more to back up nightly, which we are not going to do. We are keeping personal music and picture files on the local machine.
Question - How can I use the following script to make changes to the user's profile, during the user's logon, so that the user's My Music and My Pictures are moved and redirected to the new location, and then somehow process the redirection of My Documents to the network file share? Or is this the wrong approach?
--------------------------
----------
----------
----------
-------
const HKEY_LOCAL_MACHINE = &H80000002
const HKEY_CURRENT_USER = &H80000001
Dim objFSO, objNetwork, objShell, objReg, strComputer, strNewMyPicLinkPath, strNewMyPicLinkTarget
Dim strOldMusicFolder, strNewMusicFolder, strOldPicFolder
Dim strNewPicFolder, strNewMyMusicLinkPath, strNewMyLinkTarget, strLocalComp
Dim intNewFolder, strUserName, strMyDocLoc, objShellLink, strComputerName
Dim ReturnVal
strLocalComp = "."
Set objFSO = CreateObject("Scripting.Fi
leSystemOb
ject")
Set objNetwork = CreateObject("wScript.Netw
ork")
Set objShell = CreateObject("wScript.Shel
l")
Set objReg = GetObject("winmgmts:" & "{impersonationLevel=imper
sonate}!\\
" & strLocalComp & "\root\default:StdRegProv"
)
strUserName = objshell.ExpandEnvironment
Strings("%
username%"
)
strComputerName = objshell.ExpandEnvironment
Strings("%
ComputerNa
me%")
strOldMusicFolder = "C:\Documents and Settings\" & strUserName & "\My Documents\My Music"
strNewMusicFolder = "C:\Documents and Settings\" & strUserName & "\MyLocalData"
strNewMyMusicLinkPath = "C:\Documents and Settings\" & strUserName & "\My Documents\MyMusic.lnk"
strNewMyMusicLinkTarget = "C:\Documents and Settings\" & strUserName & "\MyLocalData\My Music"
strOldPicFolder = "C:\Documents and Settings\" & strUserName & "\My Documents\My Pictures"
strNewPicFolder = "C:\Documents and Settings\" & strUserName & "\MyLocalData"
strNewMyPicLinkPath = "C:\Documents and Settings\" & strUserName & "\My Documents\MyPictures.lnk"
strNewMyPicLinkTarget = "C:\Documents and Settings\" & strUserName & "\MyLocalData\My Pictures"
If Not objFSO.FolderExists(strNew
MusicFolde
r) Then
On Error Resume Next 'We don't want things to halt the system
objFSO.CreateFolder strNewMusicFolder
If Err.Number <> 0 Then
Msgbox Err.Number
On Error GoTo 0
Wscript.Echo VbCrLf & "Cannot create: " & strNewMusicFolder & VbCrLf & "Please Report This To Desktop Support at ext. 2157" & VbCrLf
End If
On Error GoTo 0
If objFSO.FolderExists(strNew
MusicFolde
r) Then
objFSO.MoveFolder strOldMusicFolder, strNewMusicFolder & "\"
If Err.Number <> 0 Then
Msgbox Err.Number
On Error GoTo 0
Wscript.Echo VbCrLf & "Cannot move the folder to: " & strNewMusicFolder & VbCrLf & "Please Report This To Desktop Support at ext. 2157" & VbCrLf
End If
End If
End If
If Not objFSO.FolderExists(strNew
PicFolder)
Then
On Error Resume Next 'We don't want things to halt the system
objFSO.CreateFolder strNewPicFolder
If Err.Number <> 0 Then
Msgbox Err.Number
On Error GoTo 0
Wscript.Echo VbCrLf & "Cannot create: " & strNewPicFolder & VbCrLf & "Please Report This To Desktop Support at ext. 2157" & VbCrLf
End If
On Error GoTo 0
If objFSO.FolderExists(strNew
PicFolder)
Then
objFSO.MoveFolder strOldPicFolder, strNewPicFolder & "\"
If Err.Number <> 0 Then
Msgbox Err.Number
On Error GoTo 0
Wscript.Echo VbCrLf & "Cannot move the folder to: " & strNewPicFolder & VbCrLf & "Please Report This To Desktop Support at ext. 2157" & VbCrLf
End If
End If
End If
If Not objFSO.FileExists(strNewMy
MusicLinkP
ath) Then
set objShellLink = objShell.CreateShortcut(st
rNewMyMusi
cLinkPath)
If Err.Number <> 0 Then
Msgbox Err.Number
On Error GoTo 0
Wscript.Echo VbCrLf & "Cannot create the shortcut: " & strNewMyMusicLinkPath & VbCrLf & "Please Report This To Desktop Support at ext. 2157" & VbCrLf
Else
objShellLink.TargetPath = strNewMyMusicLinkTarget
objShellLink.Description = "Link To Modified My Music Location"
objShellLink.Save
End If
End If
If Not objFSO.FileExists(strNewMy
PicLinkPat
h) Then
set objShellLink = objShell.CreateShortcut(st
rNewMyPicL
inkPath)
If Err.Number <> 0 Then
Msgbox Err.Number
On Error GoTo 0
Wscript.Echo VbCrLf & "Cannot create the shortcut: " & strNewMyPicLinkPath & VbCrLf & "Please Report This To Desktop Support at ext. 2157" & VbCrLf
Else
objShellLink.TargetPath = strNewMyPicLinkTarget
objShellLink.Description = "Link To Modified My Music Location"
objShellLink.Save
End If
End If
strKeyPath = "Software\Microsoft\Window
s\CurrentV
ersion\Exp
lorer\Shel
l Folders\"
strValueName = "My Music"
strValue = "C:\Documents and Settings\" & strUserName & "\MyLocalData\My Music"
ReturnVal = objReg.SetStringValue(HKEY
_CURRENT_U
SER,strKey
Path,strVa
lueName,st
rValue)
If (ReturnVal = 0) And (Err.Number = 0) Then
'Nothing
Else
Msgbox "SetMyMusicValue failed. Error = " & Err.Number
End If
strKeyPath = "Software\Microsoft\Window
s\CurrentV
ersion\Exp
lorer\Shel
l Folders\"
strValueName = "My Pictures"
strValue = "C:\Documents and Settings\" & strUserName & "\MyLocalData\My Pictures"
ReturnVal = objReg.SetStringValue(HKEY
_CURRENT_U
SER,strKey
Path,strVa
lueName,st
rValue)
If (ReturnVal = 0) And (Err.Number = 0) Then
'Nothing
Else
Msgbox "SetMyPicValue failed. Error = " & Err.Number
End If
Once th point We want to make certain that the redirection of the those folders to