Script to sleep PC if Sabnzbd queue is empty
Posted: May 21st, 2009, 7:29 am
I wrote this as I want my PC to come on at 4am check for downloads , download them and then go back to sleep. As sometimes there is more to download then other times there was no sure way of specifying a time to shut it down unless I said ok well max time will be 4 hours so shutdown at 8am, however sometimes it may finish in an hour so 3 hours wasted. So I wrote this VBScript to check the queue and if 0 to put PC to sleep. This is then ran as a scheduled task and repeated for 4 hours.
An easy way to wake a PC from sleep is to make a scheduled task, check this link out. http://on10.net/blogs/sarahintampa/Make ... matically/
Code: Select all
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = "False"
xmlDoc.Load("http://localhost:port/api?mode=qstatus&output=xml&ma_username=<username>&ma_password=<password>&apikey=<apikey>")
strQuery = "/queue/noofslots"
Set colItem = xmlDoc.selectNodes(strQuery)
For Each objItem in colItem
IF objitem.text = "0" Then
set objShell = wscript.createObject("wscript.shell")
objShell.Run "%comspec% /c rundll32 powrprof.dll,SetSuspendState"
Set objNet = Nothing
Else
End If
next