# Installs the EULE Outlook helper for the current Windows user (no admin rights). # # & ([scriptblock]::Create((irm 'https://siseveeb.eule.ee/Postkast/abiline/paigalda.ps1'))) # & ([scriptblock]::Create((irm 'https://siseveeb.eule.ee/Postkast/abiline/paigalda.ps1'))) -Uninstall # # It copies eule-outlook.ps1 to %LOCALAPPDATA%\EULE and registers the # eule-outlook: link type under HKCU, so "Ava Outlookis" on the Postkast page can # open a reply in Outlook Classic. # It also copies hoia-ylal.ps1 and registers the "EULE abiline - hoia ylal" scheduled # task (weekdays 08:50-18:50, every 15 min, may wake the computer) that keeps Outlook # and the Claude app running so the scheduled Postkast runs can reach the mailbox. # Skip that part with -NoKeepAlive. Kept ASCII-only (see eule-outlook.ps1). param( [switch]$Uninstall, [switch]$NoKeepAlive, [string]$Base = 'https://siseveeb.eule.ee' ) $ErrorActionPreference = 'Stop' $dir = Join-Path $env:LOCALAPPDATA 'EULE' $target = Join-Path $dir 'eule-outlook.ps1' $key = 'HKCU:\Software\Classes\eule-outlook' $keepTarget = Join-Path $dir 'hoia-ylal.ps1' $taskName = 'EULE abiline - hoia ylal' function Get-Script([string]$name, [string]$marker) { $src = (Invoke-WebRequest -UseBasicParsing -Uri "$Base/Postkast/abiline/$name").Content if ($src -is [byte[]]) { $src = [System.Text.Encoding]::UTF8.GetString($src) } if ($src -notmatch $marker) { throw "Download failed: unexpected content in $name." } return $src } if ($Uninstall) { if (Test-Path $key) { Remove-Item $key -Recurse -Force } if (Test-Path $target) { Remove-Item $target -Force } if (Get-ScheduledTask -TaskName $taskName -ErrorAction SilentlyContinue) { Unregister-ScheduledTask -TaskName $taskName -Confirm:$false } if (Test-Path $keepTarget) { Remove-Item $keepTarget -Force } Write-Host 'EULE Outlook helper removed.' -ForegroundColor Green return } New-Item -ItemType Directory -Force -Path $dir | Out-Null $src = Get-Script 'eule-outlook.ps1' 'EULE Outlook helper' Set-Content -Path $target -Value $src -Encoding UTF8 New-Item -Path $key -Force | Out-Null Set-ItemProperty -Path $key -Name '(Default)' -Value 'URL:EULE Outlook helper' Set-ItemProperty -Path $key -Name 'URL Protocol' -Value '' New-Item -Path "$key\shell\open\command" -Force | Out-Null $cmd = 'powershell.exe -NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File "' + $target + '" "%1"' Set-ItemProperty -Path "$key\shell\open\command" -Name '(Default)' -Value $cmd Write-Host "EULE Outlook helper installed: $target" -ForegroundColor Green Write-Host 'The first time you click "Ava Outlookis", the browser asks to open the link - tick "Always allow" for siseveeb.eule.ee.' if (-not $NoKeepAlive) { Set-Content -Path $keepTarget -Value (Get-Script 'hoia-ylal.ps1' 'EULE assistant keep-alive') -Encoding UTF8 $action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument ('-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File "' + $keepTarget + '"') $trigger = New-ScheduledTaskTrigger -Weekly -DaysOfWeek Monday, Tuesday, Wednesday, Thursday, Friday -At '08:50' $trigger.Repetition = (New-ScheduledTaskTrigger -Once -At '08:50' -RepetitionInterval (New-TimeSpan -Minutes 15) -RepetitionDuration (New-TimeSpan -Hours 10)).Repetition $settings = New-ScheduledTaskSettingsSet -WakeToRun -StartWhenAvailable -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit (New-TimeSpan -Minutes 5) -MultipleInstances IgnoreNew $principal = New-ScheduledTaskPrincipal -UserId ([System.Security.Principal.WindowsIdentity]::GetCurrent().Name) -LogonType Interactive -RunLevel Limited Register-ScheduledTask -TaskName $taskName -Action $action -Trigger $trigger -Settings $settings -Principal $principal -Description 'Keeps Outlook and the Claude app running on workdays for the Postkast assistant. Never touches mail.' -Force | Out-Null Write-Host "Keep-alive task registered: '$taskName' (log: $dir\hoia-ylal.log)" -ForegroundColor Green Write-Host 'Tip: in Windows power settings, allow wake timers so the task can wake the computer.' }