?
Solved

VB Script reboot with button to abort

Posted on 2011-10-04
7
Medium Priority
?
453 Views
Last Modified: 2012-05-12
I am looking for a VB Script to reboot the computer with a button to abort it.

I am using batch script shutdown -r -t xx but if this can integrate with VB function "MsgBox" that would be nice.

Thanks!
0
Comment
Question by:Mazdajai
  • 5
  • 2
7 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 36913485
Hi, something like this should work.

Regards,

Rob.
intSeconds = 30
Set objShell = CreateObject("WScript.Shell")
objShell.Run "shutdown -r -t " & intSeconds, 1, False
intReturn = objShell.Popup("Do you want to abort the shutdown?", intSeconds, "Abort shutdown?", vbYesNo)
If intReturn = 6 Then
	objShell.Run "shutdown -a", 1, True
End If

Open in new window

0
 
LVL 21

Author Comment

by:Mazdajai
ID: 36913829
Is it possible to bring the popup window to the front? The shutdown window is currently blocking the dialog box...

Thanks.
0
 
LVL 21

Author Comment

by:Mazdajai
ID: 36913863
...Or position the popup window so the users can see it at a glance?
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 21

Author Comment

by:Mazdajai
ID: 36913913
Adding vbSystemModal solved the problem. Thanks.
0
 
LVL 21

Author Comment

by:Mazdajai
ID: 36913922
Wait....Using a shortcut to call the vbs place the popup behind again...
0
 
LVL 65

Accepted Solution

by:
RobSampson earned 2000 total points
ID: 36914564
If you just add a small wait before this line:
intReturn = objShell.Popup("Do you want to abort the shutdown?", intSeconds, "Abort shutdown?", vbYesNo)

by putting this
WScript.Sleep 1000

does that help?

Rob.
0
 
LVL 21

Author Comment

by:Mazdajai
ID: 36935933
Rob,

Yes it does help. Thanks!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to writing scripts for a Client/Server computing environment it is essential to consider some way of enabling the authentication functionality within a script. This sort of consideration mainly comes into the picture when we are dealin…
AutoHotkey is an excellent, free, open source programming/scripting language for Windows. It started out as a keyboard/mouse macros product, but has expanded into a robust language. This article provides an introduction to it, with links to addition…
Integration Management Part 2
Screencast - Getting to Know the Pipeline
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question