Add a Desktop and Start Menu launcher for the Comfy host agent.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user