Why is everyone so quick to say this cannot be done? This is very easy to do with WMI.
I've broken the script into pieces so you can see how I'm performing each step.
arrAccounts = Array("UserA", "UserB")
For Each strUser in arrAccounts
WScript.Echo GetUserDesktop(GetSID(strUser))
Next
Function GetUserDesktop(strSID)
Const HKEY_USERS = &H80000003
strComputer = "."
Set objRegistry = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" _
& strComputer & "\root\default:StdRegProv")
strKeyPath = strSID & "\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders"
strValueName = "Desktop"
objRegistry.GetStringValue HKEY_USERS, strKeyPath, strValueName, strValue
GetUserDesktop = strValue
End Function
Function GetSID(strUser)
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
' Get the computer name (using WMI)
For Each objComputer In objWMIService.ExecQuery("Select * from Win32_ComputerSystem")
strComputerName = objComputer.Name
Exit For
Next
' You could just as easily do this...
' strComputerName = CreateObject("WScript.Network").ComputerName
Set objAccount = objWMIService.Get _
("Win32_UserAccount.Name='" & strUser & "',Domain='" & strComputerName & "'")
GetSID = objAccount.SID
End Function
Just be aware that Microsoft advises against using the registry to determine the location of user shell folders. There is no guarantee that this method will continue to work in future versions of Windows, but it does work in the ones you intend to target so why not use it?