|
|
|||||||
How can I query the system for session ID number when a terminal services session is on. I need that number to writte a key in the server registry in order to identificate and configurate in the right way, by a script, a shared printer. The key ends with the session number. Something like that: HKEY_CURRENT_USER\Printers\DevModePerUser] "HP LaserJet 4L/MARKO-001/Sesion 3" = hex:48,00,50,00,20,00,4c,00,61,00,73,00,65,\ 00,72,00,4a,00,65,00,74,00,20,00,34,00,4c,00,2f,00,41,00,53,00,45,00,52,00,\2d,00,30,00…………………………………………………………………………… In each session this "\session x" change his value. That's is why I need capture the string value. Anybody can help me? Thank's a lot |
||||||||
|
|
|||||||
Do you have this environment variable available in your client session (WINSTATIONNAME=ICA-tcp#136)? Is the number after the # what your looking for? If so use instr and substr to extract it. |
||||||||
|
|
|||||||
Here is a solution to your ID issue. There is a tool called "query" on Terminal Servers that can be exploited. code:shell "%comspec% /c query session @userID 1>session.txt" [ 30 March 2002, 05:46: Message edited by: Howard Bullock ] |
||||||||
|
|
|||||||
Howard, Regarding the environment variable idea: %WinstationName% is only for NT 4.0 TS The variable was changed to %SessionName% in 2000 TS In both flavors, the environment variable reports "Console" when you logon from the console. The environment variable's name is somewhat misleading. It is neither the Winstation name nor the Session name. It is actually a combination of the connection name, followed by a pound symbol and then the session ID. %ClientName% will only be populated if client session (not console session). The logic should follow: code:if @InWin=1 |
||||||||
|
|
|||||||
I found a case on NT4 TS where the environment did NOT hold up. The session ID reported by the GUI Admin tool was different than what followed the # sign in the environment variable. That is why I then posted the query.exe solution. |