|
58 | 58 | echo Dependencies installed successfully. |
59 | 59 | echo. |
60 | 60 | call :offer_listener_startup |
| 61 | +call :offer_tray_startup |
61 | 62 | goto :end_ok |
62 | 63 |
|
63 | 64 | :find_python |
@@ -124,3 +125,46 @@ goto :end_ok |
124 | 125 |
|
125 | 126 | :listener_startup_done |
126 | 127 | exit /b 0 |
| 128 | + |
| 129 | +:: ---------------------------------------------- |
| 130 | +:: Helper: Offer Tray auto-start on login |
| 131 | +:: ---------------------------------------------- |
| 132 | +:offer_tray_startup |
| 133 | + echo. |
| 134 | + echo Chronos Tray provides quick timer and schedule controls from the system tray. |
| 135 | + echo You can have it start automatically when you sign in to Windows. |
| 136 | + echo. |
| 137 | + choice /C YN /N /M "Add 'Chronos Tray' to your Startup folder so it runs on sign-in? [Y/N]: " |
| 138 | + if errorlevel 2 goto tray_startup_no |
| 139 | + if errorlevel 1 goto tray_startup_yes |
| 140 | + goto tray_startup_done |
| 141 | + |
| 142 | +:tray_startup_yes |
| 143 | + if not exist "%ROOT_DIR%tray_launcher.bat" ( |
| 144 | + echo Warning: tray_launcher.bat not found. Skipping tray shortcut creation. |
| 145 | + goto tray_startup_done |
| 146 | + ) |
| 147 | + echo Creating Startup shortcut for Chronos Tray... |
| 148 | + powershell -NoProfile -Command ^ |
| 149 | + "$shell = New-Object -ComObject WScript.Shell; " ^ |
| 150 | + "$startup = [Environment]::GetFolderPath('Startup'); " ^ |
| 151 | + "$target = Join-Path -Path '%ROOT_DIR%' -ChildPath 'tray_launcher.bat'; " ^ |
| 152 | + "$shortcutPath = Join-Path -Path $startup -ChildPath 'Chronos Tray.lnk'; " ^ |
| 153 | + "$shortcut = $shell.CreateShortcut($shortcutPath); " ^ |
| 154 | + "$shortcut.TargetPath = $target; " ^ |
| 155 | + "$shortcut.WorkingDirectory = '%ROOT_DIR%'; " ^ |
| 156 | + "$shortcut.WindowStyle = 7; " ^ |
| 157 | + "$shortcut.Save()" |
| 158 | + if %ERRORLEVEL% EQU 0 ( |
| 159 | + echo Added 'Chronos Tray' shortcut to your Startup folder. |
| 160 | + ) else ( |
| 161 | + echo Warning: Failed to create Startup shortcut automatically. |
| 162 | + echo You can still run the tray via tray_launcher.bat. |
| 163 | + ) |
| 164 | + goto tray_startup_done |
| 165 | + |
| 166 | +:tray_startup_no |
| 167 | + echo Skipping tray Startup shortcut. You can enable it later by rerunning this script. |
| 168 | + |
| 169 | +:tray_startup_done |
| 170 | + exit /b 0 |
0 commit comments