# SelfCheck.ps1 - Detailed environment diagnostic tool $InstallDir = "C:\ProgramData\ClassNotify" $configPath = Join-Path $InstallDir "appsettings.json" Write-Host "=========================================" -ForegroundColor Cyan Write-Host " ClassNotify 运行环境与组件健康自检 " -ForegroundColor Cyan Write-Host "=========================================" -ForegroundColor Cyan $report = [PSCustomObject]@{ WindowsService = "Missing" UiProcess = "Stopped" ConfigValid = (Test-Path $configPath) TtsAvailable = $false DnsResolution = $false } # 1. Service $svc = Get-Service -Name "ClassNotifyService" -ErrorAction SilentlyContinue if ($svc) { $report.WindowsService = $svc.Status.ToString() } # 2. UI Process $proc = Get-Process -Name "ClassNotify.Client" -ErrorAction SilentlyContinue if ($proc) { $report.UiProcess = "Running" } # 3. TTS try { Add-Type -AssemblyName System.Speech -ErrorAction Stop $synth = New-Object System.Speech.Synthesis.SpeechSynthesizer if ($synth.GetInstalledVoices().Count -gt 0) { $report.TtsAvailable = $true } $synth.Dispose() } catch {} # 4. Network DNS if (Test-Path $configPath) { try { $cfg = Get-Content -Path $configPath -Raw | ConvertFrom-Json $uri = [System.Uri]$cfg.ClassNotify.ServerUrl if ([System.Net.Dns]::GetHostAddresses($uri.DnsSafeHost).Length -gt 0) { $report.DnsResolution = $true } } catch {} } $report | Format-List