diff --git a/Updater/Update-Service.ps1 b/Updater/Update-Service.ps1 index 7a6ec29792c93ca691eaaa811c9b2ca7c2a7ab90..26c4c2a4a38c7eeff7b39116614713eda3a19b9c 100644 --- a/Updater/Update-Service.ps1 +++ b/Updater/Update-Service.ps1 @@ -66,6 +66,26 @@ function Stop-TrayApp() { } +function Create-TrayAppStartupShortcut() { + $StartupDir = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup" + $ShortcutFile = "$($StartupDir)\AutoTxTray.lnk" + if (Test-Path -Type Leaf $ShortcutFile) { + Write-Verbose "Startup menu shortcut already existing." + Return + } + try { + $WshShell = New-Object -ComObject WScript.Shell + $Shortcut = $WshShell.CreateShortcut($ShortcutFile) + $Shortcut.TargetPath = "$($InstallationPath)\ATxTray.exe" + $Shortcut.Save() + Log-Debug "Created startup menu shortcut for tray app." + } + catch { + Log-Debug "Creating tray app shortcut failed: $($_.Exception.Message)" + } +} + + function Exit-IfDirMissing([string]$DirName, [string]$Desc) { if (Test-Path -PathType Container $DirName) { Write-Verbose "Verified $($Desc) path: [$($DirName)]" @@ -674,6 +694,8 @@ catch { Log-Error $UpdDetails } +Create-TrayAppStartupShortcut + Send-MailReport -Subject "$UpdSummary" -Body "$UpdDetails"