System reboot

Posted on 2006-03-23
Last Modified: 2010-04-07
i have looked around the net and found a few pieces of code that say it shutsdown the system but not mine.
i have a command button and all i want it to do is reboot the system.

can u help

Question by:pastiesrus
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    Can you please show us what you have already attempted to use?

    Author Comment

    Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
    Private Const EWX_REBOOT = 2

    Private Sub cmdShutDown()
        ExitWindowsEx EWX_REBOOT, 2
    End Sub

    LVL 85

    Accepted Solution

    That may not work if you don't have the proper priviledges to issue the Reboot command.

    Take a look at the code here:


    Author Comment

    note to future viewers.

    The code i used to reboot was:

    Shell ("C:\Windows\System32\Shutdown -r")

    Works great

    Happy codeing
    LVL 85

    Expert Comment

    by:Mike Tomlinson
    Just be aware that you are using an external EXE called "shutdown" that may not be present on all systems.

    It can be moved or deleted easily.    =)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    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

    Suggested Solutions

    Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    759 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

    10 Experts available now in Live!

    Get 1:1 Help Now