473,396 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Rebooting from a vb.net app

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
5 966
"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
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

"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
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

"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Al-ahmadi | last post by:
Hi EveryBody: Is there any way to add the rebooting code to the user interface of the setup project in VB.net ? if the answer is yes,how can I do it ? but if the answer is no, Is there any way...
0
by: Todd Bright | last post by:
I have a Windows service that I wrote in C#. It uses a form in another thread to keep it running because we needed some user interface activity. When the service is running the machine will NOT...
2
by: mr_amitkulkarni | last post by:
Hello Friends, Objective : I'm working on a trivial solution for an issue like if my server/pc hangs at any moment it should reboot automatically. proposed Solution : I'll be using an external...
4
by: A | last post by:
Anyone have any code to reboot from a C# app?
2
by: Brady Kelly | last post by:
When I use the ExitWindowsEx function in my C# console application it doesn't reboot. Any ideas why?
8
by: Steve Teeples | last post by:
I am trying to use WMI to reboot my system. I have admin privileges. I've tried two different solutions but both fail for separate reasons. private void button1_Click(object sender,...
1
by: Josh | last post by:
The error I am getting is the following. ALong with the error asp doesnt start and the web site is down until I reregister asp service. Event Type: Error Event Source: ASP.NET...
1
by: Al-ahmadi | last post by:
Hi EveryBody: Is there any way to add the rebooting code to the user interface of the setup project in VB.net ? if the answer is yes,how can I do it ? but if the answer is no, Is there any way...
7
by: Raju5725 | last post by:
Hi All, How can I Change Local Machine IP Address without rebooting the machine using VB.Net. As I want to shift from one IP address to another IP address with application the effect should...
3
by: spoonone | last post by:
Hi my daughters PC keeps rebooting, when it first loads, tried to Boot into safe mode, which I can not access, tried Windows Repair can't get in to give her password, tried making it a slave on my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.