This contains miscellaneous info from Terminal Services newsgroup posts (usually my own) which contain information that isn't FAQ-ish but was of interest to me.
Edit this VBScript for the right log file path and server names. Then schedule it to run at the intervals you want using Task Scheduler. You can do it from any server that has TS installed on it (or even from an XP Pro system, since it has qwinsta installed).
NOTE: the shell command "find" is CASE-SENSITIVE. This means
that on a Metaframe XP system the script as shown will return 0 users, since it
is searching for the word "Active" and the Metaframe version of the
command shows "active". To make this work on Metaframe, change the line
UserCount = UBound(Filter(users,"Active")) + 1
to
UserCount = UBound(Filter(users,"active")) + 1
'CountUsers.vbs
logfile = "C:\Tmp\connectedusers.txt"
hosts = Array( "server1", "server2", "server3", _
"server4", "server5", "server6")
fAppend logfile, vbCrlf & "==============" _
& vbCrLf & Now & vbCrLf & "==============" & vbCrLf
For Each Host in Hosts
users = Split(Cmd("qwinsta /SERVER:" & host), vbCrLf)
UserCount = UBound(Filter(users,"Active")) + 1
fAppend logfile, Host & ": " & UserCount & vbCrLf
Next
Function Cmd(cmdline)
' Wrapper for getting StdOut from a console command
Dim Sh, FSO, fOut, OutF, sCmd
Set Sh = createobject("WScript.Shell")
Set FSO = createobject("Scripting.FileSystemObject")
fOut = FSO.GetTempName
sCmd = "%COMSPEC% /c " & cmdline & " >" & fOut
Sh.Run sCmd, 0, True
If FSO.FileExists(fOut) Then
If FSO.GetFile(fOut).Size>0 Then
Set OutF = FSO.OpenTextFile(fOut)
Cmd = OutF.Readall
OutF.Close
End If
FSO.DeleteFile(fOut)
End If
End Function
Sub fAppend(FilePath, sData)
'Given the path to a file, will append sData to it
With CreateObject("Scripting.FileSystemObject")._
OpenTextFile(FilePath, 8, True)
.Write sData: .Close
End With
End Sub
First, if you're using the connect.asp, you may need to make some mods to
make sure it still works with the updated client systems and the new TSWeb on
the server (due to changes discussed in MS02-046 and MS02-047).
In general, there is nothing to prevent you from making up your own server
variables and then sticking them into the window_onLoad event of the connect.asp
file.
Here's the one problem, which will take some tweaking possibly. You need to
escape "\", ":", and space characters in paths so they won't choke your URL,
then read them in and unescape them.
So the path to
C:\Program Files\Microsoft Office\Office\Winword.exe
you would have to stick in your URL like this when you connect to the page(all
one line stuck in the URL):
AppName=C%3A%5CProgram%20Files%5CMicrosoft%20Office%5COffice%5CWinword.exe
Then you need to unescape it in the page. This is the general routine that I _THINK_ will work (or be close to it) for most connect.asp configs. It would go in the window_onLoad for your connect.asp file. Watch out, the 2nd line is going to wrap:
If not "<%Response.Write Request.QueryString("AppName")%>" = "" then
MsTsc.SecuredSettings.StartProgram = "<%Response.Write Request.QueryString(escape("AppName"))%>"
End If
---------------------
This leaves you with the question: "How do I figure out the path name to the app
correctly?"
Here's a VBScript that will escape the path for you so you can see what it needs
to be:
'escpath.vbs
path = Inputbox("Paste the server-side EXE path here")
esc_path = escape(path)
Inputbox "This is the escaped path - Ctl-C to copy",,esc_path
Create a VBScript file - mine is logon.vbs, and I put it in the System32
directory where usrlogon.cmd is, so everyone normally has read rights to
it.
This is the text of the logon.vbs:
----------------------------------------
Set Sh = CreateObject("WScript.Shell")
sys = Sh.ExpandEnvironmentStrings("%CLIENTNAME%")
User = CreateObject("WScript.Network").Username
Sh.LogEvent 4, "Logon by " & User & " from " & sys
----------------------------------------
You need to call it from usrlogon.cmd. I added this line right after
the initial "@echo off" in usrlogon.cmd to make sure it always gets
executed:
----------------------------------------
start logon.vbs
----------------------------------------
In the server's Application log, you will see these showing up with WSH
as the event source; it will show the user logon name as well as the
source computer name.
Iain Sandercock and I discussed determining application mode for a Terminal Server by checking registry keys. He came up with some Citrix material.
news:2d8601c25fae$21a8e420$3bef2ecf@TKMSFTNGXA10
The other thing that I found out when doing looking for
this is how to also identify if Citrix is being used and
if so what version(which I thought I'd post as often
people will be using both of these product sets)
The registry keys for them are:
Citrix Metaframe 1.0 For TSE
HKLM\System\CurrentControlSet\Control\Citrix
ProductVersion=2.10
Citrix Metaframe 1.8 For TSE
HKLM\System\CurrentControlSet\Control\Citrix
ProductVersion=2.18
Citrix Metaframe 1.8 For W2k
HKLM\System\CurrentControlSet\Control\Citrix
ProductVersion=2.19
Citrix Metaframe XP
HKLM\System\CurrentControlSet\Control\Citrix
ProductVersion=2.21