Here's the dillema. We will be migrating a lot of users from physical desktops to virtual desktops. So naturally, we need to move any pst files from the local file system to the storage system which is the easy part.
Where I am currently struggling is figuring out how to modify the 001f6700 REG_BINARY value to reflect the new location of the pst file(s).
So, the function I am trying to use is shown below. When I run the script the SetBinaryValue method runs and generates no errors but the value still shows the local path and appears to be untouched by the script. Based off of some posts I have been reading I may not be formating the data within arrBinaryValueName properly before using the SetBinaryValue method.
Any help would be greatly appreciated. Apologies if an answer to this has already been posted but I have been searching all over the inet and only found a few treads talking about this specific issue.
Bryan
Code:Function WriteNewLocation(strWriteKey) Dim newAsciiName, arrBinaryValueName strSplitter = Split(strWriteKey, ";", -1, 1) PSTFileNameOld = LCase(strSplitter(0)) p_PSTRGuidReg = strSplitter(1) objPSTLog.WriteLine(p_PSTRGuidReg) strArray = Split(PSTFileNameOld, "\") For Each arr In strArray If InStr(arr, ".pst") Then strFileName = arr End If Next BinaryValueName = strServer & strFileName MsgBox BinaryValueName If InStr(PSTFileNameOld,strFile) <> 0 Then BinaryValueName = Replace(PSTFileNameOld,PSTFileNameOld,BinaryValueName) End If objPSTLog.WriteLine "Now fixing " & BinaryValueName max = len(BinaryValueName) For intLoop = 1 to Max step 1 'convert to ascii asciiName = asc(mid(BinaryValueName, intLoop, 1)) If newAsciiName = "" and newAsciiInitials = "" Then newAsciiName = asciiName Else newAsciiName = newAsciiName & "," & "00" & "," & asciiName End If If intLoop <= 2 then newAsciiInitials = newAsciiName & "," & "00" End If Next newAsciiName = newAsciiName & "," & "00," & "00," & "00" newAsciiName = Replace(newAsciiName, "\", "") 'remove "\" newAsciiName = Replace(newAsciiName, vbCr, "") 'remove Cr and Lf separately, in case return is not vbCrLf newAsciiName = Replace(newAsciiName, vbLf, "") newAsciiName = "&H"&Replace(newAsciiName, ",", ",&H") If Right(newAsciiName, 1) = "," Then newAsciiName = Left(newAsciiName, (len(newAsciiName) - 1)) 'Remove any trailing comma End If MsgBox newAsciiName arrBinaryValueName = Split(newAsciiName,",") 'convert to an array strMoniker = "winMgmts:\\.\root\default:StdRegProv" Set oReg1 = GetObject(strMoniker) strPSTEnd = oReg1.SetBinaryValue(HKEY_CURRENT_USER, strSplitter(1), r_PSTFile, arrBinaryValueName) 'Change the binary value If (Return = 0) And (Err.Number = 0) Then WScript.Echo "Binary value changed successfully!" Else WScript.Echo Err.Number & " " & Err.Description End If On Error Resume Next objPSTLog.WriteLine "Deleting value: HKEY_CURRENT_USER\" & strSplitter(1) & "\01020fff" oReg1.DeleteValue HKEY_CURRENT_USER, strSplitter(1), r_PSTFile2 End Function





Reply With Quote