VB script to shutdown computer...

I'd like help on writing a vb script that will shutdown computer but also give the option to the user to cancel the shutdown and if there is no response within a few minutes then the computer will shut down. I am planing to schedule this script to run at a certain time.

Thanks in advance.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ramromconsultant Commented:
Set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Exec("shutdown /s /t 100 /c ""shutdown /a to abort""")

Open in new window

where 100 is time in seconds.

Experts Exchange Solution brought to you by ConnectWise

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
begeorgeAuthor Commented:
Thanks a lot for the quick answer. I need to display a message like "your computer will shutdown in 2 min...."
begeorgeAuthor Commented:
I found out how to change message but the computer shuts down even if I click close. I need a way for them to cancel the shutdown. Also is there a way to play a sound to alert them of the message? Thanks
ramromconsultant Commented:
Say more about the situation. What will trigger the script? Will it run in the user's session or some other (service?) session?

We need to separate this into:
 a conversation with the user
 followed by (as appropriate) the shutdown command.
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.

All Courses

From novice to tech pro — start learning today.