473,566 Members | 3,342 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Shutdown windows 2000 from C# application

Hi All,

I have a requirement where i have to Shutdown Windows 2000
from a C# Application, my application is running as
windows
service.

When I shutdown Windows it should not reboot again, It
should power down.

please help me to resolve this.

Thanks,
Madhava
Jul 21 '05 #1
2 7010
Look there:

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

José

"Madhava Patro" <mp****@rudolph tech.com> a écrit dans le message de
news:07******** *************** *****@phx.gbl.. .
Hi All,

I have a requirement where i have to Shutdown Windows 2000
from a C# Application, my application is running as
windows
service.

When I shutdown Windows it should not reboot again, It
should power down.

please help me to resolve this.

Thanks,
Madhava

Jul 21 '05 #2

Hi Madhava,

You can use .Net Pinvoke to interop with the Win32 API functions
ExitWindowsEx to shut down the computer.
Because your caller process must have SE_SHUTDOWN_NAM E privilege, you also
should interop some API functions to adjust its privilege, such as
AdjustTokenPriv ileges.

For sample code, please refer to:
http://msdn.microsoft.com/library/de...us/sysinfo/bas
e/shutting_down.a sp

Hope this helps,

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Madhava Patro" <mp****@rudolph tech.com>
| Sender: "Madhava Patro" <mp****@rudolph tech.com>
| Subject: Shutdown windows 2000 from C# application
| Date: Mon, 6 Oct 2003 13:26:44 -0700
| Lines: 16
| Message-ID: <07************ *************** *@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcOMSCiNEf07b67 hTsiNgQ2OOR9JNg ==
| Newsgroups: microsoft.publi c.dotnet.genera l
| Path: cpmsftngxa06.ph x.gbl
| Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.genera l:110942
| NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
| X-Tomcat-NG: microsoft.publi c.dotnet.genera l
|
| Hi All,
|
| I have a requirement where i have to Shutdown Windows 2000
| from a C# Application, my application is running as
| windows
| service.
|
| When I shutdown Windows it should not reboot again, It
| should power down.
|
| please help me to resolve this.
|
| Thanks,
| Madhava
|
|
|

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2755
by: Jonathan Heath | last post by:
Hi all, I have created an ASP script that enters data into an Access Database. My problem is that I'd like this script to run when the computer is shutdown or the user logs off. I think this would be simple enough if the ASP didn't have any user input, but it does.
4
7112
by: Bill Sonia | last post by:
I'm written a Windows Service to send e-mails on events like OnStart, OnStop, OnShutDown using System.Web.Mail. It works for everything but OnShutdown. My guess is that once my send mail code is executed, other necessary Windows Services have been terminated before it can actually send the mail. I've updated my...
8
4171
by: Bill Sonia | last post by:
I've written a Windows Service to send e-mails on events like OnStart, OnStop, OnShutDown using System.Web.Mail. It works for everything but OnShutdown. My guess is that for OnShutDown, once my send mail code is executed, other necessary Windows Services have been terminated before it can actually send the mail. I've updated my...
3
3305
by: Mohammad-Reza | last post by:
Hi everybody I want to shutdown my computer with my program. I searched in MSDN to find a .NET method that can do that but did'nt find anything but ExitWindowsEx Api. I write following codes to execute this api but every time i use it, I see an error message. Error:1314 " A required privilege is not held by the client. ". Please tell me...
6
8746
by: carbon_dragon | last post by:
Ok, so here is the problem. I'm working on a headless server program implemented as a .NET C# Console project. There is a UPS mounted to this server (though not a windows compliant UPS). I can only talk to the UPS over a special device driver. Through this device driver I can detect that the UPS is going to notify Windows 2000 server to...
6
2449
by: Mr Newbie | last post by:
Whatever I do I cant programatically make my machine shutdown. I am using the following class and have tried both thte ExitWindowsEx and InititateSystemShutdownEx shared functions Neither seem to work. I have also made sure that the assembly had full trust. Can anyone suggest what may be wrong ????? Imports System.Runtime.InteropServices...
2
277
by: Madhava Patro | last post by:
Hi All, I have a requirement where i have to Shutdown Windows 2000 from a C# Application, my application is running as windows service. When I shutdown Windows it should not reboot again, It should power down.
2
2555
by: Sin Jeong-hun | last post by:
I created a windows form application. It has a Threading.Timer and when the timer ticks it does some work and show a popup window. The problem is that while this program is running if the user tries to shutdown Windows, my application doesn't quit and neither does Windows. Of course, if the user first click of my application and then...
3
4278
by: IdleBrain | last post by:
Gurus, I am trying to delay Windows Shutdown/Restart to perfrom cleanup and I am using the following code: protected override void WndProc(ref Message ex)
0
7673
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7584
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7893
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8109
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7645
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7953
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1202
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
926
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.