By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,575 Members | 1,853 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,575 IT Pros & Developers. It's quick & easy.

Rebooting from a vb.net app

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"NetworkElf" <su**@somedomain.com> schrieb:
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.


Your declares are wrong. Solution:

<URL:http://www.mentalis.org/soft/class.qpx?id=7>

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2

P: n/a
Take a look at my example. Its also on the MSDN website:

http://www.gotdotnet.com/Community/U...c-4a9a89d47fad

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #3

P: n/a

"Crouchie1998" <cr**********@spamcop.net> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
Take a look at my example. Its also on the MSDN website:

http://www.gotdotnet.com/Community/U...c-4a9a89d47fad
Crouchie1998
BA (HONS) MCP MCSE


Thanks to both you and Herfried. I've got it running and am now working on
creating a deployment for it. Obviously, I've got a lot of reading to do...

ne.
Nov 21 '05 #4

P: n/a
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
Nov 21 '05 #5

P: n/a

"Crouchie1998" <cr**********@spamcop.net> wrote in message
news:um**************@tk2msftngp13.phx.gbl...
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.
Nov 21 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.