You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

31 lines
1.2 KiB

Option Explicit
' Hidden launcher for the DSH memory bridge. Double-click friendly: no params, no window.
' If the bridge is already listening on 8766 it exits silently. Otherwise it starts the
' supervisor hidden and redirects output to scripts\supervisor.log.
Dim fso, sh, scriptDir, root, logPath
Set fso = CreateObject("Scripting.FileSystemObject")
Set sh = CreateObject("WScript.Shell")
scriptDir = fso.GetParentFolderName(WScript.ScriptFullName)
root = fso.GetParentFolderName(scriptDir)
logPath = scriptDir & "\supervisor.log"
Function PortOpen()
Dim code
code = sh.Run("powershell -NoProfile -ExecutionPolicy Bypass -Command ""if (Get-NetTCPConnection -LocalPort 8766 -State Listen -ErrorAction SilentlyContinue) { exit 0 } else { exit 1 }""", 0, True)
PortOpen = (code = 0)
End Function
If PortOpen() Then
WScript.Quit 0
End If
sh.CurrentDirectory = root
sh.Run "cmd /c node """ & scriptDir & "\supervisor.js"" >> """ & logPath & """ 2>&1", 0, False
WScript.Sleep 5000
If Not PortOpen() Then
MsgBox "DSH Memory bridge did not start within 5 seconds." & vbCrLf & vbCrLf & _
"Log: " & logPath & vbCrLf & vbCrLf & _
"Possible causes: node not in PATH, port 8766 blocked, config missing.", 48, "DSH Memory"
End If