• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 455
  • Last Modified:

VB Script reboot with button to abort

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
Mazdajai
Asked:
Mazdajai
  • 5
  • 2
1 Solution
 
RobSampsonCommented:
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
 
MazdajaiAuthor Commented:
Is it possible to bring the popup window to the front? The shutdown window is currently blocking the dialog box...

Thanks.
0
 
MazdajaiAuthor Commented:
...Or position the popup window so the users can see it at a glance?
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

 
MazdajaiAuthor Commented:
Adding vbSystemModal solved the problem. Thanks.
0
 
MazdajaiAuthor Commented:
Wait....Using a shortcut to call the vbs place the popup behind again...
0
 
RobSampsonCommented:
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
 
MazdajaiAuthor Commented:
Rob,

Yes it does help. Thanks!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now