Skip to content
Snippets Groups Projects
Commit ea618b2b authored by Niko Ehrenfeuchter's avatar Niko Ehrenfeuchter :keyboard:
Browse files

Register the tray app for auto-start on user login.

Fixes #30
parent a4fd172d
No related branches found
No related tags found
No related merge requests found
...@@ -66,6 +66,26 @@ function Stop-TrayApp() { ...@@ -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) { function Exit-IfDirMissing([string]$DirName, [string]$Desc) {
if (Test-Path -PathType Container $DirName) { if (Test-Path -PathType Container $DirName) {
Write-Verbose "Verified $($Desc) path: [$($DirName)]" Write-Verbose "Verified $($Desc) path: [$($DirName)]"
...@@ -674,6 +694,8 @@ catch { ...@@ -674,6 +694,8 @@ catch {
Log-Error $UpdDetails Log-Error $UpdDetails
} }
Create-TrayAppStartupShortcut
Send-MailReport -Subject "$UpdSummary" -Body "$UpdDetails" Send-MailReport -Subject "$UpdSummary" -Body "$UpdDetails"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment