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-
Printable View
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-
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
Well, this is cool, but how can I get the timer stuff?
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 ..
Or if you dont mind them seeing the Shutdown Dialog box, you can have it show the timer ..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
Shutdown = "shutdown -s -t 1800"
BTW, to abort the shutdown enter shutdown -a in cmd prompt.
Wel, I've got this now:
But, How can I get the second messagebox like the first one: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
In taskbar and disabled close button
And both massageboxes: forever on foreground?
Thanks in advance,
Thomas
or is this inpossible?
i dont think I understand .. you want a second messagebox .. but one that has it's buttons disabled?
I've got that messagebox.Code:Answer = objShell2.Popup("Saving time...", 30, "Shut down!")
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
is in the taskbar, and has a disabled close button. but is also not forever on foreground. so that I want forever on foreground.Code:Question = MsgBox("Turn Off Computer in 30 Minutes?", vbYesNo, "Shutdown")
Hopefully it's now clear.
Greetings,
Thomas
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.
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.