Home

Google
 

Terminal Server Problem - I am unable to create a Terminal Server Session


If you find that you are unable to create a Terminal Server session to a Windows 2000 or 2003 server then the following troubleshooting steps may assist you:

  1. Check compare the following registry keys with a working Terminal server of the same platform:
  2. HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\TermDD

    And HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\TermService

  3. If you find missing values on the problem server, backup the mentioned registry keys to safe location and import the keys from the working machine.
  4. Check these registry keys as well:
  5. HKEY_LOCAL_MACHINE\\System\CurrentControlSet\Enum\Root

    1. LEGACY_RDPWD

    2. LEGACY_TDTCP

    3. LEGACY_TERMDD

    4. LEGACY_RDPDD

    5. LEGACY_TDTCP

  6. Check in the %systemroot\system32 folder for the following files and if missing copy over from a working machine at the same OS and service pack level:
  7. Rdpclip.exe

    Rdpcfgex.dll

    Rdpdd.dll

    Rdpwsx.dll

    Tsappcmp.dll

    Tscon.exe

    Tsdincon.exe

    Tskill.exe

    Tslabels.h

    Tslabels.ini

    Tsprof.exe

    Tsshutdn.exe

How do I Remotely Terminate all Windows Terminal Server Sessions with Vbscript?

‘ This vbscript finds all active Terminal Server sessions on server HOST defined
‘ below and terminates them. Does not terminate the
‘ current session if being run remotely.
‘ If running on local host, set HOST value to “.”

HOST = “.”

‘ Get disconnected sessions and log them off
sessions = DisconnectedSessions(HOST)

For each session in sessions
TerminateWinSession HOST, sessionId
Next

‘ Now get active sessions and log them off
sessions = ActiveSessions(HOST)

For each session in sessions
TerminateWinSession HOST, sessionId
Next

Sub TerminateWinSession(Host, sessionId)
Dim Sh, tmpHost
Set Sh = createobject(”WScript.Shell”)
if trim(Host)=”" Then
tmpHost = “”
Else
tmpHost = ” /SERVER:” & Host
End If
Sh.Run “%COMSPEC% /C rwinsta ” & sessionId & tmpHost, 0, False
End Sub

Function ActiveSessions(Host)
Dim tmpHost, aTmp, aTmp1(), i
if trim(Host)=”" Then
tmpHost = “”
Else
tmpHost = ” /SERVER:” & Host
End If
aTmp = Split(cmd(”qwinsta” & tmpHost & ” | find “”Active”"”), _
vbCrLf)
ReDim aTmp1(-1)
For i = 0 to UBound(aTmp)
If Left(aTmp(i),1) <> “>” Then
Redim Preserve aTmp1(UBound(aTmp1) + 1)
aTmp1(UBound(aTmp1)) = Trim(Mid(aTmp(i), 42, 6))
End If
Next
ActiveSessions = aTmp1
End Function

Function DisconnectedSessions(Host)
Dim tmpHost, aTmp, aTmp1(), i
if trim(Host)=”" Then
tmpHost = “”
Else
tmpHost = ” /SERVER:” & Host
End If
aTmp = Split(cmd(”qwinsta” & tmpHost & ” | find “”Disconnected”"”), _
vbCrLf)
ReDim aTmp1(-1)
For i = 0 to UBound(aTmp)
If Left(aTmp(i),1) <> “>” Then
Redim Preserve aTmp1(UBound(aTmp1) + 1)
aTmp1(UBound(aTmp1)) = Trim(Mid(aTmp(i), 42, 6))
End If
Next
DisconnectedSessions = aTmp1
End Function

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


powered by FreeFind