Results 1 to 10 of 10

Thread: [RESOLVED]shut down computer after 30 minuts

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    178

    Resolved [RESOLVED]shut down computer after 30 minuts

    I'm searching for a vbscript that asks if you computer schould be turned off after 30 minutes, and if you push yes, the computer will be shutted down.

    Thanks,
    Thomas

    -Solved with WB.NET-
    Last edited by Mindstorms; Nov 17th, 2007 at 08:09 AM.

  2. #2
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: shut down computer after 30 minuts

    once you get the timer part (30 minutes thing) this will ask if you want to shut down .. note. Shows Dos window .. and BTW if you answer yes it will shutdown right away.

    Code:
    Option Explicit
    
    Dim objShell, Question, Shutdown
    Question = MsgBox("Turn Off Computer?", vbYesNo, "Shutdown")
    
    If Question = vbYes Then
        Shutdown = "shutdown -s -t 00"
        Set objShell = CreateObject("WScript.Shell")
        objShell.Run "cmd"
        Wscript.Sleep 100
        objShell.SendKeys Shutdown
        objShell.SendKeys "{ENTER}"
    End if

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    178

    Re: shut down computer after 30 minuts

    Well, this is cool, but how can I get the timer stuff?

  4. #4
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: shut down computer after 30 minuts

    Wscript.Sleep 1800000

    I think that is 30 minutes, not sure what kind of limit is on Wscipt.Sleep though .. but 1000 is 1 second.

    So would be like ..

    Code:
    Option Explicit
    
    Dim objShell, Question, Shutdown
    Question = MsgBox("Turn Off Computer in 30 Minutes?", vbYesNo, "Shutdown")
    
    If Question = vbYes Then
        Wscript.Sleep 1800000
        Shutdown = "shutdown -s -t 00"
        Set objShell = CreateObject("WScript.Shell")
        objShell.Run "cmd"
        Wscript.Sleep 100
        objShell.SendKeys Shutdown
        objShell.SendKeys "{ENTER}"
    End if
    Or if you dont mind them seeing the Shutdown Dialog box, you can have it show the timer ..

    Shutdown = "shutdown -s -t 1800"

    BTW, to abort the shutdown enter shutdown -a in cmd prompt.
    Last edited by rory; Dec 5th, 2006 at 03:48 PM.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    178

    Re: shut down computer after 30 minuts

    Wel, I've got this now:

    Code:
    Option Explicit
    
    Dim objShell, Question, Shutdown
    Question = MsgBox("Turn Off Computer in 30 Minutes?", vbYesNo, "Shutdown")
    If Question = vbYes Then
    	Wscript.Sleep 1800000
         
    	Dim objShell2 
    	Dim Answer 
    	Set objShell2 = CreateObject("Wscript.Shell") 
    	Answer = objShell2.Popup("Saving time...", 30, "Shut down!") 
    	Set objShell2 = Nothing 
    	
        Shutdown = "shutdown -s -t 180"
        Set objShell = CreateObject("WScript.Shell")
        objShell.Run "cmd"
        Wscript.Sleep 100
        objShell.SendKeys Shutdown
        objShell.SendKeys "{ENTER}"
        objShell.SendKeys "exit"
        objShell.SendKeys "{ENTER}"
    End if
    But, How can I get the second messagebox like the first one:
    In taskbar and disabled close button
    And both massageboxes: forever on foreground?

    Thanks in advance,
    Thomas

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    178

    Re: shut down computer after 30 minuts

    or is this inpossible?

  7. #7
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: shut down computer after 30 minuts

    i dont think I understand .. you want a second messagebox .. but one that has it's buttons disabled?

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jul 2006
    Posts
    178

    Re: shut down computer after 30 minuts

    Code:
    Answer = objShell2.Popup("Saving time...", 30, "Shut down!")
    I've got that messagebox.

    But that messagebox has got an enabled close button, and is not forever on foreground and you don't see him in the taskbar. I want an disabled close button, forever on foreground and that you see him in the taskbar, just like the first one.

    And the first messagebox
    Code:
    Question = MsgBox("Turn Off Computer in 30 Minutes?", vbYesNo, "Shutdown")
    is in the taskbar, and has a disabled close button. but is also not forever on foreground. so that I want forever on foreground.

    Hopefully it's now clear.

    Greetings,
    Thomas

  9. #9
    PowerPoster
    Join Date
    May 2006
    Posts
    2,988

    Re: shut down computer after 30 minuts

    im pretty sure you would need an exe to do what you want, but i'll check tomorrow .. see vbscript is not a Gui language, it is typically used for tasks and messages with very little, if any, user interacton, so basically pop up messages are as far as it will go, by default.

  10. #10
    New Member
    Join Date
    Dec 2006
    Posts
    11

    Re: shut down computer after 30 minuts

    Try this:
    Question = MsgBox("Turn Off Computer in 30 Minutes?", vbYesNo + vbSystemModal, "Shutdown")
    Answer = objShell2.Popup("Saving time...", 30, "Shut down!", 4096)

    It will force the message boxes to stay in the foreground, but still cannot disable the Close control.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width