VB script to shutdown computer...

Posted on 2012-09-12
Medium Priority
Last Modified: 2012-09-15
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.
Question by:begeorge
  • 2
  • 2
LVL 17

Accepted Solution

ramrom earned 1500 total points
ID: 38393373
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.

Author Comment

ID: 38393808
Thanks a lot for the quick answer. I need to display a message like "your computer will shutdown in 2 min...."

Author Comment

ID: 38393832
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
LVL 17

Expert Comment

ID: 38402493
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.

Featured Post

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.

Question has a verified solution.

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

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
Integration Management Part 2
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

807 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