VBS Script to Shutdown Computers

Posted on 2011-10-15
Last Modified: 2012-06-27
Hey everyone,

I know this exists because I’ve seen different forms of it but not exactly what I’m looking for. I’m looking for a VBS script that I can push out with group policy and scheduled tasks for our XP, Vista, Win 7 machines that will prompt a user that their computer will shut down in 60 seconds to save energy. Press Ok to shut down immediately or press Cancel to keep working. And if the user does nothing it will force terminate all applications and shutdown the computer at the end of 60 seconds. Can anyone help me out with this?

Question by:swthpk32
    LVL 7

    Expert Comment


    Author Comment

    The concept is right but I don’t want to do it by OU. I want to copy it to the local machine; use GPO scheduled task's to execute it at a set time. But if a user is working at that set time they have the option to cancel it or click ok to shut it down right away or it just times out after 60 seconds and does it for them.
    LVL 6

    Expert Comment


    Accepted Solution


    The last one is pretty close but it would need to be tweaked for what im looking for. I just found one i can get to work!

    Author Comment

    Will a VBS still work if the computer is still locked?
    LVL 65

    Expert Comment

    Hi, what about a script like this?

    intSeconds = 60
    Set objShell = CreateObject("WScript.Shell")
    objShell.Run "shutdown -s -f -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


    Author Closing Comment

    I found it on my own on another site

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Several part series to implement Internet Explorer 11 Enterprise Mode
    This is an article about Leadership and accepting and adapting to new challenges. It focuses mostly on upgrading to Windows 10.
    In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
    The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now