473,386 Members | 1,652 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,386 software developers and data experts.

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 6994
Look there:

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

José

"Madhava Patro" <mp****@rudolphtech.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_NAME privilege, you also
should interop some API functions to adjust its privilege, such as
AdjustTokenPrivileges.

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

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****@rudolphtech.com>
| Sender: "Madhava Patro" <mp****@rudolphtech.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: AcOMSCiNEf07b67hTsiNgQ2OOR9JNg==
| Newsgroups: microsoft.public.dotnet.general
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.general:110942
| NNTP-Posting-Host: TK2MSFTNGXA09 10.40.1.161
| X-Tomcat-NG: microsoft.public.dotnet.general
|
| 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
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...
4
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...
8
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...
3
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...
6
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...
6
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...
2
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...
2
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...
3
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
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
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...

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.