5 changed files with 101 additions and 6 deletions
@ -0,0 +1,26 @@
@@ -0,0 +1,26 @@
|
||||
# Creates a desktop shortcut "DSH Memory" that starts the bridge hidden and idempotently. |
||||
# Run once: powershell -NoProfile -ExecutionPolicy Bypass -File V:\Site\dsh-memory\scripts\create-desktop-shortcut.ps1 |
||||
$ErrorActionPreference = 'Stop' |
||||
$scriptsDir = $PSScriptRoot |
||||
$root = Split-Path -Parent $scriptsDir |
||||
$vbs = Join-Path $scriptsDir 'launch-dsh-memory.vbs' |
||||
if (-not (Test-Path $vbs)) { throw "launch-dsh-memory.vbs not found: $vbs" } |
||||
|
||||
$desktop = [Environment]::GetFolderPath('Desktop') |
||||
$lnk = Join-Path $desktop 'DSH Memory.lnk' |
||||
|
||||
$node = Get-Command node -ErrorAction SilentlyContinue |
||||
$iconPath = if ($node) { $node.Source } else { "$env:SystemRoot\System32\shell32.dll" } |
||||
|
||||
$ws = New-Object -ComObject WScript.Shell |
||||
$s = $ws.CreateShortcut($lnk) |
||||
$s.TargetPath = 'wscript.exe' |
||||
$s.Arguments = '"' + $vbs + '"' |
||||
$s.WorkingDirectory = $root |
||||
$s.IconLocation = "$iconPath,0" |
||||
$s.Description = 'Start DSH Memory bridge (silent, no duplicates)' |
||||
$s.WindowStyle = 1 |
||||
$s.Save() |
||||
|
||||
Write-Host "Shortcut created: $lnk" |
||||
Write-Host "Double-click it to start the bridge. If the bridge is already running, nothing happens." |
||||
@ -0,0 +1,31 @@
@@ -0,0 +1,31 @@
|
||||
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 |
||||
Loading…
Reference in new issue