# Kill any stale Task Scheduler approach Unregister-ScheduledTask -TaskName 'JARVIS-Agent' -Confirm:$false -ErrorAction SilentlyContinue # Create a VBScript launcher (runs Python silently, no console window) $vbs = 'Set WShell = CreateObject("WScript.Shell")' + "`r`n" + 'WShell.Run """C:\Users\myron\AppData\Local\Programs\Python\Python312\pythonw.exe"" ""C:\ProgramData\jarvis-agent\jarvis-agent.py""", 0, False' [System.IO.File]::WriteAllText('C:\ProgramData\jarvis-agent\start-agent.vbs', $vbs, [System.Text.ASCIIEncoding]::new()) # Add to user startup folder so it runs at every login $startupDir = "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup" Copy-Item 'C:\ProgramData\jarvis-agent\start-agent.vbs' "$startupDir\JARVIS-Agent.vbs" -Force Write-Host "Startup entry created: $startupDir\JARVIS-Agent.vbs" -ForegroundColor Green # Kill any existing python process running the agent Get-Process python*, pythonw* -ErrorAction SilentlyContinue | Where-Object {$_.CommandLine -like '*jarvis-agent*'} | Stop-Process -Force -ErrorAction SilentlyContinue # Launch now Write-Host "Starting agent..." -ForegroundColor Cyan Start-Process 'C:\Users\myron\AppData\Local\Programs\Python\Python312\pythonw.exe' -ArgumentList 'C:\ProgramData\jarvis-agent\jarvis-agent.py' -WorkingDirectory 'C:\ProgramData\jarvis-agent' Start-Sleep -Seconds 4 # Confirm running $proc = Get-Process pythonw -ErrorAction SilentlyContinue if ($proc) { Write-Host "Agent running — PID $($proc.Id)" -ForegroundColor Green } else { Write-Host "pythonw not found — check C:\ProgramData\jarvis-agent\jarvis-agent.log" -ForegroundColor Yellow } # Show log tail Start-Sleep -Seconds 2 if (Test-Path 'C:\ProgramData\jarvis-agent\jarvis-agent.log') { Write-Host "`nLog:" -ForegroundColor Cyan Get-Content 'C:\ProgramData\jarvis-agent\jarvis-agent.log' -Tail 10 }