PC Sleep Timer

Discussion in 'Code Snippets and Tutorials' started by Milanos, Oct 20, 2007.

Thread Status:
Not open for further replies.
  1. Milanos

    Milanos Level IV

    Joined:
    Nov 2, 2006
    Messages:
    1,771
    Likes Received:
    12
    Location:
    In your nose
    I found this on a site, and I hope it may be helpful for some.

    if you run this script, you can choose in how many minutes the PC must shut down, which might come in handy if you're downloading something and you want to shut down your PC after that, or if you're running a cheat program ;)

    Anyway, this is the code :

    on error resume next
    a = InputBox("After how many minutes must the PC shut down ?: " & vbcrlf & vbcrlf &"60 minutes is 1 hour....", "�hi-tech-web.com - PC sleep timer!", "Your time in minutes.")
    If a = clear Then
    Wscript.Quit
    end if
    If a < 1 Then
    MsgBox "this number is too small!!!", Vbcritical ,"�hi-tech-web.com - PC sleep timer!"
    Wscript.Quit
    End if
    do
    Wscript.sleep 60000
    a = a - 1
    loop until a = 0
    Set OpSysSet = GetObject("winmgmts:{(Shutdown)}//./root/cimv2").ExecQuery("select * from Win32_OperatingSystem where Primary=true")
    for each OpSys in OpSysSet
    OpSys.ShutDown()
    next
    Msgbox ("The PC is now shutting down."), vbCritical, "�hi-tech-web.com - PC sleep timer!"
    Wscript.Quit

    Just copy that in notepad, and save it somewhere as .vbs

    Then simply click on it, and enter the time in minutes you want it to shut down in :)

    http://www.dse.nl/~high-tech-web/

    I got it from that site, but it's in Dutch, so good luck figuring it out ;) I can translate more scripts from that page if anyone wants me too...
     
  2. fanatical

    fanatical Level I

    Joined:
    Sep 2, 2007
    Messages:
    82
    Likes Received:
    0
    Location:
    Canada
    hey that's cool !

    Another option would be to use shutdown.exe (included with most windows versions) It can be scheduled with your "scheduled tasks" (found in accesories, system tools, I think) works pretty well too ! and you can set it to shutdown each night at a specific time.

    use shutdown.exe /? to see the different options you can use with it.
     
  3. Milanos

    Milanos Level IV

    Joined:
    Nov 2, 2006
    Messages:
    1,771
    Likes Received:
    12
    Location:
    In your nose
    Yeah I know, there are even more ways. I've got a simpler one too, if anyone wants that, it's in Batch.
     
Thread Status:
Not open for further replies.