You can create a PowerShell Script named keepawake.ps1
with the following code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| param([int]$minutes=60) # input param, 60 minutes if no value provided
$wsh = New-Object -ComObject WScript.Shell
$cur = Get-Date # Current time
$tar = $cur.AddMinutes($minutes) # Target time
# $RNDSleep = Get-Random -Minimum 30 -Maximum 200
# $MINS = RNDSleep / 60
while ($cur -lt $tar) {
# Send Shift+F15
$wsh.SendKeys('+{F15}')
Start-Sleep -seconds 240 # sleep for 4 minutes
$cur = Get-Date
}
|
Use it with:
1
| powershell.exe -file keepawake.ps1 -minutes 20
|
Reference#