VB Code to log current user off NT 
Author Message
 VB Code to log current user off NT

Hello, is there a way to log the current user off NT with VB? I want to
have a program run as a login script, then when the progam ends, i want
the user's session to end. (i'm trying to do the equivilent of setting the
user's shell to the progam in UNIX)

Thank you,
 Doug Melniker

** Please cc response to me by email **



Sat, 10 Nov 2001 03:00:00 GMT  
 VB Code to log current user off NT

Quote:

> Hello, is there a way to log the current user off NT with VB? I want to
> have a program run as a login script, then when the progam ends, i want
> the user's session to end. (i'm trying to do the equivilent of setting the
> user's shell to the progam in UNIX)

> Thank you,
>  Doug Melniker

> ** Please cc response to me by email **

http://www.mvps.org/vbnet/
Search for Visual Basic Undocumented Shell32 Routines
Windows by the Numbers, Overview

Extract:
Dialog Functions (sorted by ordinal)

The "System Settings Change" message box ("You must restart your
computer before the new settings will take effect.")

Declare Function SHRestartSystemMB Lib "shell32" Alias "#59" _
(ByVal hOwner As Long, _
ByVal sExtraPrompt As String, _
ByVal uFlags As Long) As Long

hOwner = Message box owner; specify 0& for the desktop (will be
top-level)
sPrompt = Specified prompt string placed above the default prompt. The
default string can not be defeated, but additional explanation can be
provided to the user.
uFlags = Based on the OS, can be the following values:

WinNT
Appears to use ExitWindowsEx uFlags values and behave accordingly:
Public Const EWX_LOGOFF = 0
Public Const EWX_SHUTDOWN = 1 NT: needs SE_SHUTDOWN_NAME privilege (no
default prompt)
Public Const EWX_REBOOT = 2 NT: needs SE_SHUTDOWN_NAME privilege
Public Const EWX_FORCE = 4
Public Const EWX_POWEROFF = 8 NT: needs SE_SHUTDOWN_NAME privilege

Win95
Any Yes selection produces the equivalent to ExitWindowsEx(EWX_FORCE,
0&) (?), i.e. no WM_QUERYENDSESSION or WM_ENDSESSION is sent! Other than
noted below,
it was found that any other value shuts the system down (no reboot) and
includes the default prompt.

Shuts the system down (no reboot) and does not include the default
prompt.
Public Const shrsExitNoDefPrompt = 1

Reboots the system and includes the default prompt.
Public Const shrsRebootSystem = 2     ' = EWX_REBOOT

Return values: Yes = 6 (vbYes), No = 7 (vbNo)

The "Shut Down" dialog (i.e. Start menu / Shut Down)

Declare Function SHShutDownDialog Lib "shell32" Alias "#60" _
(ByVal YourGuess As Long) As Long

I have a comment here - as the author of the code specifies, this is
undocumented and might change with the next windows release.



Fri, 16 Nov 2001 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. log off current user in NT

2. Are resources still valid for an NT service after user logs off

3. Current Users Logged On to NT Server

4. VB6 - how to get the current NT logged on users (not just local PC)

5. Need help with code to Log Off User in Win95/98

6. Code to kill off Current Users

7. Code to kill off current users

8. How do i make a server program that will log and log off other users

9. VB program which keeps running even log off from NT

10. Preventing a VB app from closing when user logs off in Win '95

11. Programmatically kill user connection/log user off server.

12. Current Domain User Name of logged in user?

 

 
Powered by phpBB® Forum Software