Windows Tray Startup Skill
Silently launch Windows desktop applications at boot and hide them to the system tray, even for stubborn apps (Flutter, Electron, etc.) that ignore standard window style hints.
When to Use
- User asks to make an app start at boot and minimize/hide to tray
- App ignores
WindowStylefrom VBSws.Runor .NETProcessStartInfo - App is Flutter/Electron-based and manages its own window creation
- PowerShell
Add-Typefails due to large environment blocks (>64KB)
The Pattern
-
VBS launcher in
shell:startupfolder: delays 10s (let desktop settle), then callspythonw.exewith the script path. Usesws.Run(..., 0, False)for no window. -
Python script (
pythonw.exe— no console window):
- Starts the target app viasubprocess.Popen
- Usesctypes.windll.user32to call Win32 APIs directly (no compilation needed)
-EnumWindows+GetWindowThreadProcessIdto find app windows by PID
-ShowWindow(hwnd, 0)= SW_HIDE to hide all visible windows
- Polls every 500ms for 20 seconds to catch delayed window creation
How to Use
Step 1: Create the Python script
Copy and adapt scripts/hide_app_to_tray.py:
- Change TARGET_PATH to the app's executable path
- Adjust POLL_SECONDS and POLL_INTERVAL if the app starts faster/slower
- Test manually: pythonw path/to/script.py
Step 2: Create the VBS launcher
Set ws = CreateObject("WScript.Shell")
WScript.Sleep 10000
ws.Run "pythonw.exe ""C:\path\to\hide_app.py""", 0, False
Step 3: Install to startup
Place the VBS file in the Startup folder:
Copy-Item "launcher.vbs" "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup\"
Or keep VBS in a central scripts folder (C:\Users\<user>\AppData\Local\StartupScripts\) and create a shortcut in the Startup folder.
Key decisions
- SW_HIDE (0) vs SW_MINIMIZE (6): Use SW_HIDE if the app has a system tray icon (window hidden, only tray remains). Use SW_MINIMIZE if the app must stay in the taskbar.
- pythonw vs python: Always use
pythonw.exe— it has no console window. - VBS vs direct Python in startup: VBS provides the 10-second startup delay and
Run(..., 0)for hidden launch. Direct Python in startup may flash a console. - ctypes vs Add-Type: ctypes is always available in Python and has no environment block limitation. PowerShell's
Add-Typecompiles C# and fails when the environment block exceeds 65535 bytes (common with many PATH entries).
Script Customization
The template script scripts/hide_app_to_tray.py has these tunables near the top:
TARGET_PATH = r"C:\Program Files\Flix\Flix.exe" # App executable
POLL_SECONDS = 20 # Total polling duration
POLL_INTERVAL = 0.5 # Interval between polls (seconds)
SW_MODE = 0 # 0=SW_HIDE (tray-only), 6=SW_MINIMIZE (taskbar)