# 管理者権限の確認と自動昇格 $isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) if (-not $isAdmin) { Write-Host "[情報] 管理者権限に昇格して再実行します..." -ForegroundColor Yellow Start-Process powershell.exe -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs exit } Write-Host "========================================================" -ForegroundColor Cyan Write-Host "WSL サービスのクラッシュ時自動再起動設定 (管理者権限)" -ForegroundColor Cyan Write-Host "========================================================" -ForegroundColor Cyan Write-Host "" Write-Host "[実行中] WSLService の障害回復設定を更新しています..." -ForegroundColor Green & sc.exe failure WSLService reset= 86400 actions= restart/3000/restart/5000/restart/10000 Write-Host "" Write-Host "[確認] 現在の障害回復設定:" -ForegroundColor Green & sc.exe qfailure WSLService Write-Host "" Write-Host "========================================================" -ForegroundColor Cyan Write-Host "設定が完了しました。Enterキーを押すと終了します。" -ForegroundColor Cyan Write-Host "========================================================" -ForegroundColor Cyan Read-Host