Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XP Fast User Switching (fas) - List current users using VB .net

Status
Not open for further replies.

bonifale

Programmer
Sep 4, 2003
74
GB
Hi,

I have several machines running XP and using Fast User Switching. The code I'm writing, which runs when the user logs in, changes the version of certain files depending upon the users name. I've invoked it as shown below....
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run]
"VersionControl"="C:\\Program Files\\Mk3 Version Control\\Launch Version Control.exe"

My problem is that many users access the machines remotely using 'remote desktop connection' and do not always log off, but simply disconnect the session. This leaves the user in a 'disconnected' state. If another user logs in, my code runs and changes the files okay, appropriate for that user, but if the original user reconnects, the login code is not executed and they end up with the wrong version of the files.

Turning off Fast User Switching is sadly not an option!

Does anybody know how to obtain a list of currently logged in users using VB .NET?

 
Sorted...

I downloaded Cassia from [URL unfurl="true"]http://code.google.com/p/cassia/[/url]

Added a reference to the Cassia.dll and used this sub

Private Sub GetUserList()
Dim manager As New TerminalServicesManager()
Using server As ITerminalServer = manager.GetLocalServer
server.Open()
For Each session As ITerminalServicesSession In server.GetSessions()
If Not String.IsNullOrEmpty(session.UserName) Then Debug.Print(session.UserName)
Next
End Using
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top