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:
  1. Public Class Form1
  2.     Inherits System.Windows.Forms.Form
  3.  
  4.     Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
  5.  
  6.  
  7.     Private Enum windowsexitflags
  8.         logoff = 0
  9.         Shutdown = 1
  10.     End Enum
  11.     Private Sub btnShutdown_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnShutdown.Click
  12.         MessageBox.Show("Test before")'to see if im going through the button press
  13.         ExitWindowsEx(windowsexitflags.Shutdown, 1&)
  14.         MessageBox.Show(" Test after")
  15.     End Sub
  16.     Private Sub btnNo_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnNo.Click
  17.         ExitWindowsEx(windowsexitflags.logoff, 0&)
  18.     End Sub
  19.     Private Sub btnYes_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnYes.Click
  20.         Me.Close()
  21.     End Sub
  22. 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.