Shutdown windows 2000 from C# application

  • Thread starter Thread starter Madhava Patro
  • Start date Start date
M

Madhava Patro

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
 
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/default.asp?url=/library/en-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" <[email protected]>
| Sender: "Madhava Patro" <[email protected]>
| Subject: Shutdown windows 2000 from C# application
| Date: Mon, 6 Oct 2003 13:26:44 -0700
| Lines: 16
| Message-ID: <[email protected]>
| 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
|
|
|
 
Back
Top