Shut Down Windows 2000...?

Wolfsnap

Member
Joined
Jun 15, 2003
Messages
19
Location
North Carolina
I need to able to shut down Windows 2000 in VB.net. Im developing an application that will run on an industrial PC interface controlling a piece of machinery in a truck. When a "job" is complete, I need to shut down the interface to avoid corrupting the OS and systems on the PC (as opposed to the operator just cutting the power).

Ive got this code so far, which allows me to restart and log off, but it wont work for a full shutdown.

Code:
Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Integer, ByVal dwReserved As Integer) As Integer

Declarations
Public Enum ExitWindowsFlags
    EWX_LOGOFF = 0
    EWX_REBOOT = 2
    EWX_SHUTDOWN = 1
    EWX_FORCE = 4
End Enum
    
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    ExitWindows(0)
End Sub

I think that I need to set some sort of permissions or authorizations to do a full shutdown, but I am having no luck finding a working example to achieve this.

Any help would me EXTREMELY appreciated!

Wolf

:confused::confused:
 
Last edited by a moderator:
I know nothing about logging off winfows, but use the [ code ] tags to post code here. (dont forget to close it with a [/ code ] tag (not spaces)
 
The process needs to have the SE_SHUTDOWN_NAME privilege granted to it prior to calling [api]ExitWindowsEx[/api](). Request the privilege using [api]AdjustTokenPrivileges[/api]().
 
Back
Top