|
Rank: Advanced Member Joined: 9/14/2010 Posts: 404 Location: Minnesota
|
I have gone through extensive port changes with my screenconnect install. During all this testing the port and URL of my screenconnect relay server has changed. I created an easy vbscript to change the relay port and url on unattended machines. You need to run this before changing your port/url. Then once all computers have been changed, change your SC server URL and port as desired. Code: 'Change below to your custom values' newrelayurl = "relayurl.com" newrelayport = "443"
strComputer = "." 'could be any computer, not just the local one ' Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery _ ("Select * from Win32_Service where Name LIKE '%ScreenConnect Guest Service%'") dim temp dim OriginalImagePath For Each objService in colServiceList temp = objService.DisplayName next
const HKEY_LOCAL_MACHINE = &H80000002 strComputer = "." Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_ strComputer & "\root\default:StdRegProv") strKeyPath = "SYSTEM\CurrentControlSet\services\" & temp strValueName = "ImagePath" oReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue OriginalImagePath = strValue 'Wscript.Echo OriginalImagePath 'Find Y Dim MyArrayYFirst Dim MyArrayYSecond Dim y Dim orig MyArrayYFirst = Split(OriginalImagePath, "y=", -1, 1) MyArrayYSecond = Split(MyArrayYFirst(1), "&", -1, 1) orig = MyArrayYFirst(0) y = MyArrayYSecond(0) 'Wscript.Echo y 'Find H Dim MyArrayHFirst Dim MyArrayHSecond Dim h MyArrayHFirst = Split(OriginalImagePath, "h=", -1, 1) MyArrayHSecond = Split(MyArrayHFirst(1), "&", -1, 1) If newrelayurl = "" Then h = MyArrayHSecond(0) Else h = newrelayurl End If 'Wscript.Echo h 'Find P Dim MyArrayPFirst Dim MyArrayPSecond Dim p MyArrayPFirst = Split(OriginalImagePath, "p=", -1, 1) MyArrayPSecond = Split(MyArrayPFirst(1), "&", -1, 1) If newrelayport = "" Then p = MyArrayPSecond(0) Else p = newrelayport End If 'Wscript.Echo p 'Find K Dim MyArrayKFirst Dim MyArrayKSecond Dim k MyArrayKFirst = Split(OriginalImagePath, "k=", -1, 1) MyArrayKSecond = Split(MyArrayKFirst(1), "&", -1, 1) k = MyArrayKSecond(0) 'Wscript.Echo k 'Find a Dim MyArrayAFirst Dim MyArrayASecond Dim a MyArrayAFirst = Split(OriginalImagePath, "a=", -1, 1) MyArrayASecond = Split(MyArrayAFirst(1), "&", -1, 1) a = MyArrayASecond(0) 'Wscript.Echo a 'Find T Dim MyArrayTFirst Dim MyArrayTSecond Dim t MyArrayTFirst = Split(OriginalImagePath, "t=", -1, 1) MyArrayTSecond = Split(MyArrayTFirst(1), "&", -1, 1) t = Replace(MyArrayTSecond(0), """","") 'Wscript.Echo t
newpathname = orig & "y=" & y & "&h=" & h & "&p=" & p & "&k=" & k & "&a=" & a & "&t=" & t & """"
strKeyPath = "SYSTEM\CurrentControlSet\services\" & temp strValueName = "ImagePath" strValue = newpathname oReg.SetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
For Each objService in colServiceList objService.StopService() WSCript.Sleep 15000 objService.StartService() next
|