System reboot

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

Who is Participating?
Mike TomlinsonMiddle School Assistant TeacherCommented:
That may not work if you don't have the proper priviledges to issue the Reboot command.

Take a look at the code here:

Mike TomlinsonMiddle School Assistant TeacherCommented:
Can you please show us what you have already attempted to use?
pastiesrusAuthor Commented:
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

pastiesrusAuthor Commented:
note to future viewers.

The code i used to reboot was:

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

Works great

Happy codeing
Mike TomlinsonMiddle School Assistant TeacherCommented:
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.    =)
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.