From b7c4f01f5e8c36a55d1ce685c075cc6ab72e7d89 Mon Sep 17 00:00:00 2001 From: Towsty Date: Tue, 1 Sep 2026 07:13:43 -0500 Subject: [PATCH] Add a Desktop and Start Menu launcher for the Comfy host agent. Co-authored-by: Cursor --- .../install-comfy-host-agent-launchers.ps1 | 26 ++++++++++++++ scripts/launch-comfy-host-agent.vbs | 35 +++++++++++++++++++ scripts/start-comfy-host-agent.cmd | 5 ++- 3 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 scripts/install-comfy-host-agent-launchers.ps1 create mode 100644 scripts/launch-comfy-host-agent.vbs diff --git a/scripts/install-comfy-host-agent-launchers.ps1 b/scripts/install-comfy-host-agent-launchers.ps1 new file mode 100644 index 0000000..14dc2a2 --- /dev/null +++ b/scripts/install-comfy-host-agent-launchers.ps1 @@ -0,0 +1,26 @@ +# Installs Desktop + Start Menu shortcuts that start the Comfy host agent +# without Cursor. The scheduled task still starts the agent at logon. +$ErrorActionPreference = 'Stop' +$root = (Resolve-Path (Join-Path $PSScriptRoot '..')).Path +$vbs = Join-Path $root 'scripts\launch-comfy-host-agent.vbs' +if (-not (Test-Path $vbs)) { throw "Missing $vbs" } + +$shell = New-Object -ComObject WScript.Shell +$desktop = [Environment]::GetFolderPath('Desktop') +$programs = Join-Path ([Environment]::GetFolderPath('StartMenu')) 'Programs\AIGen' +New-Item -ItemType Directory -Force -Path $programs | Out-Null + +function Save-Shortcut([string]$dir) { + $path = Join-Path $dir 'Start Comfy Host Agent.lnk' + $lnk = $shell.CreateShortcut($path) + $lnk.TargetPath = (Join-Path $env:SystemRoot 'System32\wscript.exe') + $lnk.Arguments = "//B `"$vbs`"" + $lnk.WorkingDirectory = $root + $lnk.WindowStyle = 7 + $lnk.Description = 'Start the AIGen Comfy host agent in the background' + $lnk.Save() + $path +} + +Save-Shortcut $desktop +Save-Shortcut $programs diff --git a/scripts/launch-comfy-host-agent.vbs b/scripts/launch-comfy-host-agent.vbs new file mode 100644 index 0000000..6fc9bd3 --- /dev/null +++ b/scripts/launch-comfy-host-agent.vbs @@ -0,0 +1,35 @@ +' Start the Comfy host agent with no window. Safe to run when Cursor is closed. +' Uses the "AIGen Comfy Host Agent" scheduled task when it exists. +Option Explicit +Dim sh, fso, root, node, agent, rc +Set sh = CreateObject("WScript.Shell") +Set fso = CreateObject("Scripting.FileSystemObject") + +If AgentRunning() Then WScript.Quit 0 + +On Error Resume Next +rc = sh.Run("schtasks /run /tn ""AIGen Comfy Host Agent""", 0, True) +On Error GoTo 0 +WScript.Sleep 1200 +If AgentRunning() Then WScript.Quit 0 + +root = fso.GetParentFolderName(WScript.ScriptFullName) +root = fso.GetParentFolderName(root) +node = """C:\Program Files\nodejs\node.exe""" +agent = """" & root & "\scripts\comfy-host-agent.mjs""" +If Not fso.FileExists(Replace(node, """", "")) Then WScript.Quit 1 +sh.CurrentDirectory = root +sh.Run node & " " & agent, 0, False + +Function AgentRunning() + Dim svc, query, item + AgentRunning = False + Set svc = GetObject("winmgmts:\\.\root\cimv2") + Set query = svc.ExecQuery("SELECT CommandLine FROM Win32_Process WHERE Name='node.exe'") + For Each item In query + If InStr(LCase("" & item.CommandLine), "comfy-host-agent") > 0 Then + AgentRunning = True + Exit Function + End If + Next +End Function diff --git a/scripts/start-comfy-host-agent.cmd b/scripts/start-comfy-host-agent.cmd index c32ec58..38d5162 100644 --- a/scripts/start-comfy-host-agent.cmd +++ b/scripts/start-comfy-host-agent.cmd @@ -1,4 +1,3 @@ @echo off -REM Starts the host agent hidden. Do not leave a Command Prompt open for this. -REM Agent stays running after idle-stop (default 30 min, override with COMFY_IDLE_MS). -start "" wscript.exe //B "%~dp0start-comfy-host-agent-hidden.vbs" +REM Hidden launcher. Double-click this or the Start Menu / Desktop shortcut. +wscript.exe //B "%~dp0launch-comfy-host-agent.vbs"