hiro1357 icon

no-wake-windows2.ps1

hiro1357 | PRO | 05/24/17 02:41:25 PM UTC | 0 ⭐ | 770 👁️ | Never ⏰ | []
PowerShell |

680 B

|

None

|

0 👍

/

0 👎

# 夜中にPCが勝手にスリープ解除して困ってる人向け。
# PowerShell で実行すると、スリープ解除が有効になっているタスクを自動的に取得し、1個ずつ無効にできます。
# 実行方法はPowerShellを起動して直接コピペするだけ。
 
foreach ($task in ((schtasks /query /fo csv) -split "\n")){
  $tn = ($task -split ",")[0]
  if($tn -ne "`"タスク名`"") {
    if ((schtasks /query /xml /tn $tn | findstr WakeToRun) -like "*true*") {
      Write-Host $tn
      Write-Host "Do you want to disable this task?"
      choice
      if($LASTEXITCODE -eq 1){
        schtasks /change /tn $tn /disable
      }
    }
  }
}

Comments