Monday, February 21, 2011

Remote Assistant with Mandatory Profile

By default, you cannot launch Remote Assistant to help a user who is running on Mandatory Profile. For example, running XenDesktop + AppSense + Mandatory Profile is a good mix of technologies - however when a user having problem, you won't be able to start Remote Assistant session to their XenDesktop session.

To fix this, use the following VBScript to modify the registry:

Option Explicit
Const HKLM = &H80000002

Dim objReg, strRegKey, strRegValue, strRegData, objAdInfo, objUser, username, objWMIService, objAccount, strComputer, wmipath, oShell, usersid, domain
strComputer = "."

Set oShell = CreateObject( "WScript.Shell" )

username = oShell.ExpandEnvironmentStrings("%UserName%")
domain = oShell.ExpandEnvironmentStrings("%UserDomain%")

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
wmipath = "Win32_UserAccount.Name='" & username & "',Domain='" & domain & "'"

Set objAccount = objWMIService.Get(wmipath)
usersid = objAccount.SID

Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & ".\root\default:StdRegProv")
strRegKey = "Software\Microsoft\Windows NT\CurrentVersion\ProfileList\" & usersid & "\"

strRegValue = "State"
strRegData = "0"

objReg.SetStringValue HKLM, strRegKey, strRegValue, strRegData

WScript.Quit 0 'Return success

They way we do it, we attach this VBScript everytime the msra.exe process starts - this makes sure the "State" is set to 0 before the msra.exe process started

No comments: