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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get Terminal Server Session Id

Status
Not open for further replies.

SkreeM

IS-IT--Management
Jun 6, 2005
117
0
0
GB
Is there a way to get the terminal server session ID for the currently logged on session, i need it as part of a log in script. the session name will not do as this can change if the session is disconnected and reconnected.

Thanks In Advance
 
might just lead you up the garden path but its a start?

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_TSSessionSetting")

For Each objItem in colItems
Wscript.Echo "Active session limit: " & objItem.ActiveSessionLimit
Wscript.Echo "Broken connection action: " & objItem.BrokenConnectionAction
Wscript.Echo "Broken connection policy: " & objItem.BrokenConnectionPolicy
Wscript.Echo "Disconnected session limit: " & _
objItem.DisconnectedSessionLimit
Wscript.Echo "Idle session limit: " & objItem.IdleSessionLimit
Wscript.Echo "Reconnection policy: " & objItem.ReconnectionPolicy
Wscript.Echo "Setting ID: " & objItem.SettingID
Wscript.Echo "Terminal name: " & objItem.TerminalName
Wscript.Echo "Time limit policy: " & objItem.TimeLimitPolicy
Wscript.Echo
Next
 
You could try this???

Set wshShell = WScript.CreateObject("WScript.Shell")
strSessionName = WshShell.ExpandEnvironmentStrings("%SESSIONNAME%")

It uses CMD line through vbscript using the wshShell.expandEnvironmentStrings.
Hope this helps
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top