logo

The ConnectWise Control forum has moved to ConnectWise University! This forum has been locked and is in read-only mode. Click here for instructions on how to access the new forum.

Welcome Guest! You can not login or register.

Notification

Icon
Error

Options
Go to last post Go to first unread
bigdessert  
#1 Posted : Thursday, January 26, 2012 10:48:27 PM(UTC)
bigdessert


Rank: Advanced Member

Medals: ScreenConnect Advisor: Focus Group MemberLevel 3: Shirt off your back! Received 25 Thanks!

Joined: 9/13/2010(UTC)
Posts: 708
Location: Minnesota

Thanks: 1 times
Was thanked: 44 time(s) in 32 post(s)
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

mbressman  
#2 Posted : Monday, May 6, 2013 4:41:05 PM(UTC)
mbressman


Rank: Newbie

Medals: ScreenConnect Advisor: Focus Group Member

Joined: 5/6/2013(UTC)
Posts: 9
Location: NJ

Thanks to bigdessert for the original script, which I modified slightly. The changes are:

1) You are prompted for the newrelayurl and newrelayport
2) If the system you are on uses UAC, the script will prompt you to run it as an administrator with UAC (since sometimes, running the script on Win7 machines, etc. without UAC elevation would cause it to do nothing)
3) Caveat - if you run this on a system that doesn't have UAC (i.e. WinXP), you will get a pop-up dialog box that asks what user you want to run it as - by default it selects the logged on user, but you should uncheck "Protect my computer and data from unauthorized program activity" or I don't think the script will work
4) This should work for ScreenConnect v3.0, v3.1, and v3.2 (most current version at time of posting)
5) As mentioned in the script, if you want to change the security key, you can't do it via prompts but have to do it in the script itself. I tried doing it with prompts, but the InputBox seems limited to 254 or 255 characters, and they key was larger. If anyone knows how to fix this, please let me know!!
6) I have tested this script (with a different security key set in the script) to move a v3.0 client from one ScreenConnect server to another (the new ScreenConnect server had a different relay URL and security key) - it worked, but entries such as in add/remove programs and in services (which I believe comes from the registry) still show the old alphanumeric sequence after the ScreenConnect entry (i.e. ScreenConnect (abc) instead of ScreenConnect (def)). If you want to take a try at #5 above, feel free to try and correct this as well!

Let me know if there are any issues, and enjoy!

Code:

'This script will prompt for new relay URL and relay port
'If you want to change the key, find the line below k = MyArrayKSecond(0) and change it to k = "YourKeyHere"

'ScreenConnect Service Name in v3.0 - ScreenConnect Guest Service (...)
'ScreenConnect Service Name in v3.1 - ScreenConnect Guest Client (...)
'ScreenConnect Service Name in v3.2 - ScreenConnect Client (...)

If WScript.Arguments.Named.Exists("elevated") = False Then
	'Launch the script again as administrator
	CreateObject("Shell.Application").ShellExecute "wscript.exe", """" & WScript.ScriptFullName & """ /elevated", "", "runas", 1
	WScript.Quit
Else
	'Change the working directory from the system32 folder back to the script's folder.
	Set oShell = CreateObject("WScript.Shell")
	oShell.CurrentDirectory = CreateObject("Scripting.FileSystemObject").GetParentFolderName(WScript.ScriptFullName)
End If

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%'")
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 "orig"
'Wscript.Echo orig
'Wscript.Echo "y"
'Wscript.Echo y
'Find H
Dim MyArrayHFirst
Dim MyArrayHSecond
Dim h 
MyArrayHFirst = Split(OriginalImagePath, "h=", -1, 1)
MyArrayHSecond = Split(MyArrayHFirst(1), "&", -1, 1)
Dim newrelayurl
newrelayurl = InputBox("Enter new ScreenConnect Relay URL", ,MyArrayHSecond(0))
If newrelayurl = "" Then
Wscript.Echo "You entered nothing in the input box...quitting now"
wscript.quit
Else
h = newrelayurl
End If
'Wscript.Echo "h"
'Wscript.Echo h
'Find P
Dim MyArrayPFirst
Dim MyArrayPSecond
Dim p 
MyArrayPFirst = Split(OriginalImagePath, "p=", -1, 1)
MyArrayPSecond = Split(MyArrayPFirst(1), "&", -1, 1)
Dim newrelayport
newrelayport = InputBox("Enter new ScreenConnect Relay Port", ,MyArrayPSecond(0))
If newrelayport = "" Then
Wscript.Echo "You entered nothing in the input box...quitting now"
wscript.quit
Else
p = newrelayport
End If
'Wscript.Echo "p"
'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"
'Wscript.Echo k
'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"
'Wscript.Echo t

newpathname = orig & "y=" & y & "&h=" & h & "&p=" & p & "&k=" & k & "&t=" & t & """"

'Wscript.Echo "newpathname"
'Wscript.Echo newpathname

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

jessy5765  
#3 Posted : Friday, August 23, 2013 11:44:51 AM(UTC)
jessy5765


Rank: Advanced Member

Medals: ScreenConnect Advisor: Focus Group MemberLevel 1: Random Act of Kindness! Received One Thanks!

Joined: 1/24/2011(UTC)
Posts: 98
Man
Location: PA

Thanks: 1 times
Was thanked: 2 time(s) in 2 post(s)
Do we have anything for 4.0 on this yet?
Jessy5765
Network Engineer/Web Design & Hosting
RazorbaQ  
#4 Posted : Monday, January 6, 2014 11:03:55 PM(UTC)
RazorbaQ


Rank: Newbie

Joined: 1/6/2014(UTC)
Posts: 1
United States

bigdessert, I like the idea of the script, but that is way over my head (I don’t trust me to roll it out right). However I did find a funky little workaround that may be of some benefit to us noobs.

Here is what I setup when I installed ScreenConnect 4.0?????.
Web - <add key="WebServerListenUri" value="http://+:80/" />
Relay - <add key="RelayListenUri" value="relay://0.0.0.0:443/" />

I installed 29 clients and changed my mind on what ports to use… This is where I wanted to go…
Web - <add key="WebServerListenUri" value="https://+:443/" />
Relay - <add key="RelayListenUri" value="relay://0.0.0.0:8041/" />

Can anyone spot the problems? I like a noob, not knowing the difficulties in changing the relay port, I used port 443. After calling SC and speaking with tech support, (Whom by the way are, US based and super friendly) pointed me at your script as the closest solution. Now, on to my funky workaround.

First, my server is behind a router and I’m using port forwards to access it from the outside world. Here are the rules to start.
Web portal
Server.Domain.com:80 forward to 192.168.111.111:80
Relay
Server.Domain.com:443 forward to 192.168.111.111:443
This will take down you relay server to a few minutes. As long as you are not using Screen Connect to manage your server, and you can go without it for 5 minutes, you should be fine.

1) Edit the web.config file to reflect the new relay port you desire (8041), and restart the Screen Connect servers. Remember to verify that your firewall has to new ports open and the old ports closed. This will take down your relay connection!

2) Change the internal relay port forward in your router, pointing it to the new relay port you desire. (Server.Domain.com:443 to 192.168.111.111:8041). Remember to leave the external port alone for the time being, just change the internal target port. Relay connections should be back up. See, that was fast and probably less than 5 min too.

3) Add a rule to your router for the new external port you are migrating to. (Server.Domain.com:8041 to 192.168.111.111:8041).
Recap: Both 443 and 8041 are ported to the internal port 8041 of your server which should be setup to use the new port.

4) Log in to your Screen Connect web portal, click “Host”, click “All Machines” click the check box to select all machines.

5) Right click and Reinstall. This will push out a new client to all machines with the new relay port settings.

6) Get a cup of coffee; evacuate the last cup, or both depending on your specific needs.

7) Remove the port forward in your router for the old relay port. (443)

Your relay port has now been changed.
I then walked through the modifications need to change my web port from 80 to 443 using the newly freed up port in my router.
With and luck this makes sense to anyone else with a similar issue.

Edited by user Monday, January 6, 2014 11:06:35 PM(UTC)  | Reason: Not specified

Users browsing this topic
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.