# EULE assistant keep-alive - keeps the work computer ready for the scheduled Postkast runs. # # Run by a Windows scheduled task (registered by paigalda.ps1) on weekdays every # 15 minutes from 08:50 to 18:50. Each run: # 1. resets the idle-sleep timer, so the computer does not fall asleep during work hours # (the task itself is allowed to wake the computer); # 2. starts Outlook Classic minimized if it is not running; # 3. starts the Claude desktop app if it is not running (the cloud runs reach Outlook through it). # It never reads, sends or changes mail. Log: %LOCALAPPDATA%\EULE\hoia-ylal.log (last 300 lines). # # Kept ASCII-only on purpose: Windows PowerShell 5.1 reads downloaded scripts # without a BOM as ANSI. $ErrorActionPreference = 'Continue' $logDir = Join-Path $env:LOCALAPPDATA 'EULE' $log = Join-Path $logDir 'hoia-ylal.log' New-Item -ItemType Directory -Force -Path $logDir | Out-Null function Write-Log([string]$msg) { $line = (Get-Date -Format 'yyyy-MM-dd HH:mm:ss') + ' ' + $msg Add-Content -Path $log -Value $line -Encoding UTF8 } function Find-Outlook { foreach ($k in @('HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE', 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE')) { try { $p = (Get-ItemProperty -Path $k -ErrorAction Stop).'(default)' if ($p -and (Test-Path $p)) { return $p } } catch { } } return $null } function Find-Claude { $candidates = @( (Join-Path $env:LOCALAPPDATA 'AnthropicClaude\claude.exe'), (Join-Path $env:LOCALAPPDATA 'Programs\Claude\Claude.exe'), (Join-Path $env:LOCALAPPDATA 'Programs\claude-desktop\Claude.exe') ) foreach ($c in $candidates) { if (Test-Path $c) { return $c } } return $null } # 1. Reset the idle-sleep timer (ES_SYSTEM_REQUIRED, not continuous: the normal sleep # timeout applies again once these runs stop in the evening). try { Add-Type -Namespace EULE -Name Power -MemberDefinition '[DllImport("kernel32.dll")] public static extern uint SetThreadExecutionState(uint esFlags);' -ErrorAction SilentlyContinue [void][EULE.Power]::SetThreadExecutionState([uint32]1) } catch { Write-Log ('sleep timer reset failed: ' + $_.Exception.Message) } # 2. Outlook Classic if (-not (Get-Process -Name 'OUTLOOK' -ErrorAction SilentlyContinue)) { $exe = Find-Outlook if ($exe) { try { Start-Process -FilePath $exe -WindowStyle Minimized Write-Log 'Outlook was not running - started.' } catch { Write-Log ('Outlook start failed: ' + $_.Exception.Message) } } else { Write-Log 'Outlook was not running and OUTLOOK.EXE was not found.' } } # 3. Claude desktop app if (-not (Get-Process -Name 'claude' -ErrorAction SilentlyContinue)) { $claude = Find-Claude if ($claude) { try { Start-Process -FilePath $claude -WindowStyle Minimized Write-Log 'Claude desktop app was not running - started.' } catch { Write-Log ('Claude start failed: ' + $_.Exception.Message) } } else { Write-Log 'Claude desktop app was not running and claude.exe was not found (set its path in Find-Claude).' } } # Keep the log short. try { $lines = Get-Content -Path $log -ErrorAction SilentlyContinue if ($lines -and $lines.Count -gt 300) { $lines | Select-Object -Last 300 | Set-Content -Path $log -Encoding UTF8 } } catch { }