41 lines
1.3 KiB
PowerShell
41 lines
1.3 KiB
PowerShell
param (
|
|
[Single]$Hours = 1,
|
|
|
|
[Single]$Minutes = 0,
|
|
|
|
[Single]$grace_minutes = 2
|
|
)
|
|
|
|
# some calcs
|
|
$wait_minutes = (($Hours*60)+$Minutes)
|
|
$wait_seconds = ($wait_minutes*60)
|
|
$total_wait_minutes = ($wait_minutes+$grace_minutes)
|
|
$grace_seconds = ($grace_minutes*60)
|
|
|
|
Write-Host "wait_seconds $wait_seconds wait_minutes $wait_minutes hours $Hours minutes $Minutes grace_seconds $grace_seconds grace_minutes $grace_minutes total_wait_minutes $total_wait_minutes"
|
|
|
|
# schedule chkdsk to take up fuckin tons of time
|
|
chkdsk /r C:
|
|
|
|
Write-Host "`nFORCING YOUR STUPID ASS OFF IN $Hours hours $Minutes minutes plus $grace_minutes minutes grace period`n"
|
|
|
|
# current time
|
|
Write-Host "$(Get-Date -Format 'hh:mm:ss tt') | Start Time"
|
|
|
|
# shutdown time
|
|
Write-Host "$((Get-Date).AddHours($Hours).AddMinutes($total_wait_minutes).ToString("hh:mm:ss tt")) | Reboot Time"
|
|
|
|
Write-Host "`nSleeping for $Hours hours $Minutes minutes...`n"
|
|
|
|
# sleep
|
|
Start-Sleep -Seconds $wait_seconds
|
|
|
|
# force reboot
|
|
## terminal notice
|
|
Write-Host "FORCING REBOOT IN $grace_minutes MINUTES"
|
|
## popup
|
|
$shell = New-Object -ComObject 'WScript.Shell'
|
|
$shell.Popup("REBOOTING BY FORCE IN $grace_minutes", 0, "REBOOTING AS FUCK IN $grace_minutes", 0)
|
|
## reboot, force, delay $grace_seconds seconds
|
|
## cancel with shutdown /a
|
|
shutdown /r /f /t $grace_seconds |