Rebooting from a vb.net app

  • Thread starter Thread starter NetworkElf
  • Start date Start date
N

NetworkElf

Hi all,

I'm trying to create an app that will reboot the machine upon which it is
running. I've set up ExitWindowsEx as shown below, but I seem to have done
something wrong, as nothing happens when the button associated with the
reboot command is pushed.

From what I can see of the code I have googled, the syntax looks right.
Would someone please give me a nudge in the right direction?

Thank you.



Public Class Form1
Inherits System.Windows.Forms.Form
Const EWX_REBOOT = 2
Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As
Long, _
ByVal dwReserved As Long) As Long


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim lr As Long

lr& = ExitWindowsEx(EWX_REBOOT, 0)
MsgBox(lr)

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
End
End Sub
End Class
 
Mine is a fully working VB.NET example, but please give me a mention in your
application if you use my code because I was the first to post the code on
the Internet for VB.NET.

Crouchie1998
BA (HONS) MCP MCSE
 
Crouchie1998 said:
Mine is a fully working VB.NET example, but please give me a mention in your
application if you use my code because I was the first to post the code on
the Internet for VB.NET.

Crouchie1998
BA (HONS) MCP MCSE

Actually, it seems that my little app will not go into production. The user
said that a server needed to be rebooted automatically once a day, so I
decided that this would be a good learning project for vb.net and started
working on it.

However, it seems that what really happening is that a set of services are
being stopped/started each morning and when the application to which they
are related has communications issues. I'll take that up as a project when I
return from leave.

Thanks again.

ne.
 
Back
Top