?
Solved

VB script to shutdown computer...

Posted on 2012-09-12
4
Medium Priority
?
457 Views
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.
0
Comment
Question by:begeorge
  • 2
  • 2
4 Comments
 
LVL 17

Accepted Solution

by:
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.
0
 

Author Comment

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

Author Comment

by:begeorge
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
0
 
LVL 17

Expert Comment

by:ramrom
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.
0

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