|
-
Dec 4th, 2006, 12:42 PM
#1
Thread Starter
Addicted Member
[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.
-
Dec 5th, 2006, 06:23 AM
#2
PowerPoster
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
-
Dec 5th, 2006, 09:42 AM
#3
Thread Starter
Addicted Member
Re: shut down computer after 30 minuts
Well, this is cool, but how can I get the timer stuff?
-
Dec 5th, 2006, 03:44 PM
#4
PowerPoster
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.
-
Dec 8th, 2006, 11:11 AM
#5
Thread Starter
Addicted Member
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
-
Dec 9th, 2006, 11:14 AM
#6
Thread Starter
Addicted Member
Re: shut down computer after 30 minuts
-
Dec 10th, 2006, 01:20 AM
#7
PowerPoster
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?
-
Dec 10th, 2006, 04:59 AM
#8
Thread Starter
Addicted Member
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
-
Dec 10th, 2006, 05:04 AM
#9
PowerPoster
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.
-
Dec 14th, 2006, 03:55 PM
#10
New Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|