Hello, I have reviewd many of the threads here on how to shutdown a system and created this code using the VB.NET cookbooks solution.
VB Code:
Public Class Form1 Inherits System.Windows.Forms.Form Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long Private Enum windowsexitflags logoff = 0 Shutdown = 1 End Enum Private Sub btnShutdown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShutdown.Click MessageBox.Show("Test before")'to see if im going through the button press ExitWindowsEx(windowsexitflags.Shutdown, 1&) MessageBox.Show(" Test after") End Sub Private Sub btnNo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNo.Click ExitWindowsEx(windowsexitflags.logoff, 0&) End Sub Private Sub btnYes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnYes.Click Me.Close() End Sub End Class
MY Problem is LOGOFF works, SHUTDOWN does not... I do not understand why. Console app is being run on a windows XP SP2 box under administrative privilges. Any sugestions would be appreciated.




Reply With Quote