IF you do not like using Microsoft API calls like ExitWindowsEx, but you still want to Shutdown, Restart, and/or Log Out a computer, you can use some simple shell based code. The Shell method works fine but requires the Windows Shutdown service to be active on the target computer to work. IT usually is running by default on most computers. Also using these codes won’t require your calling application to register with Windows for higher or “special” priviledges like you would if you used the ExitWindowsEx API.
Update: I went ahead and added the VB 6.0 version of this code after the Visual Basic.NET version. The .NET code works with version Visual Basic 2008, VB 2010, and newer as well.
Update #2: Thanks to Robbin for pointing out at the Process Class will NOT execute the Shutdown service to perform the commands. I was assuming it would and just added the required flags. So you can just use the same Shell method that VB 6.0 for .NET.
Shell "shutdown -s" 'Shutdown Shell "shutdown -r" 'Restart Shell "shutdown -l" 'Log Out