File: //var/opt/nydus/ops/customer_local_ops/operating_system/powershell/shutdown_ovh_vm.ps1
try {
Set-ItemProperty -Path "REGISTRY::HKEY_USERS\.DEFAULT\Control Panel\Desktop" -Name "WaitToKillAppTimeout" -Value "20000" -Type String
Set-ItemProperty -Path "REGISTRY::HKEY_USERS\.DEFAULT\Control Panel\Desktop" -Name "HungAppTimeout" -Value "20000" -Type String
Set-ItemProperty -Path "REGISTRY::HKEY_USERS\.DEFAULT\Control Panel\Desktop" -Name "AutoEndTasks" -Value "1" -Type String
Set-ItemProperty -Path "REGISTRY::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control" -Name "WaitToKillServiceTimeout" -Value "60000" -Type String
Write-Host "Attempting graceful shutdown..."
Stop-Computer -Force -Confirm:$false -ErrorAction Stop
}
catch {
Write-Host "Graceful shutdown failed. Preparing for forced shutdown..."
Add-Type -AssemblyName PresentationFramework
[System.Windows.MessageBox]::Show("The system will shut down in 2 minutes. Please save your work..")
Start-Sleep -Seconds 120
Stop-Computer -Force
}