• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

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

Pastiesrus
0
pastiesrus
Asked:
pastiesrus
  • 3
  • 2
1 Solution
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
Can you please show us what you have already attempted to use?
0
 
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

0
 
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:
http://www.experts-exchange.com/Programming/Programming_Languages/Visual_Basic/Q_21597246.html


0
 
pastiesrusAuthor Commented:
note to future viewers.

The code i used to reboot was:

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

Works great

Happy codeing
0
 
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.    =)
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now