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

Terminal server in application server mode

Status
Not open for further replies.

cluM09

Technical User
May 15, 2004
127
US
I have a need to determine if the terminal server is running in a Remote Administration mode or Application Server mode.

I have searched all over the net for the script, but I have never found anything that I can use to check for the terminal server mode.

Any idea where I can find the script that can do the check will be greatly appreciated.

Thanks!
 
Check out win32_terminalservicesetting class. In particular, its licencingtype property and changemode method.
 
tsuji,

Thank you for your response!

I was able to get Terminal Server mode from what you suggested for Windows Server 2003, but I cannot get the mode for Windows 2000 Server. Microsoft already indicated that this WMI provider only works with Windows XP or Windows Server 2003. The code is listed below:

----------------------------------------------------------
Option Explicit

Dim strComputer, objWMIService, colClass, objClass, strMode

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colClass = objWMIService.ExecQuery("Select * from Win32_TerminalServiceSetting")

For Each objClass in colClass
strMode = objClass.TerminalServerMode
If strMode = 1 Then
Wscript.Echo "Terminal Server is in Application Server mode."
Else
Wscript.Echo "Terminal Server is in Remote Administration mode."
End If
Next

Set objWMIService = Nothing
Set colClass = Nothing
Set objClass = Nothing
------------------------------------------------------------

However, I can use it to check for Windows Server 2003.

Thanks again!
 
Does it need to be a script? You can find this easily in the WIndows Terminal Services Config.
 
djtech2k,

Thank you for your response!

Yes, it has to be a script to check for TS mode since I need to integrate this with my other script that I am writing.
 
ok. Well, my best guess at this point is to have a vbscript read from the registry to find out whether it is in app or admin mode. I would suggest looking into this registry key for TS:

HKLM\System\CurrentControlSet\Control\Terminal Server

I am not 100% sure what key it is, but I would think its in there. Your vbscript could then tell you the value and do what you want it to based on that value.

Does that help? If you need more help, lemme know.
 
Ok, I am not 100% sure about this, but this code may work to find the mode:

Code:
Option Explicit

Dim WSHShell, RegKey, TSMode, Result

Set WSHShell = CreateObject("WScript.Shell")

RegKey = "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\"

TSMode = WSHShell.RegRead (regkey & "TSUserEnabled")

wscript.echo "Terminal Server Mode: " & TSMode

Again, I am not sure if this registry key is 100% correct to determine the mode, but I think it is. I know the code works fine. You will just need to check some of your server for the key value make sure its consistent. It should be that if the value here is 0, then it is in Admin mode.

Let me know.
 
djtech2k,

Thanks for the response!

Actually, the registry location that I found is in the script below. I don't know how reliable it is, but at least for the time being I can use it.

-----------------------------------------------------
Option Explicit

Dim strComputer, objWMIService, strKeyPath, strValueName, dwValue, oReg, tsMode

Const HKEY_LOCAL_MACHINE = &H80000002
strKeyPath = "SYSTEM\CurrentControlSet\Control\Terminal Server"
strValueName = "TSAppCompat"

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set oReg = GetObject("winMgmts:\\" & strComputer & "\root\default:StdRegProv")

tsMode = oReg.GetDWORDValue(HKEY_LOCAL_MACHINE, strKeyPath, strValueName, dwValue)

If Not IsNull(dwValue) Then
If dwValue = 1 Then
Wscript.Echo Space(2) & "Terminal Server is in Application Server mode."
Else
Wscript.Echo Space(2) & "Terminal Server is in Remote Administration mode."
End If
End If
---------------------------------------------------------

CluM09
 
Well, I am afraid that it really will not tell you what you want to know. That key relates to the setting of "compatability mode" for TS. I am not sure, but I think that can be done in admin mode as well. Otherwise, the logic is basically the same as mine.

The key I used in my code was most common for admin mode on my servers. However, I do not think it is a 100% deal. I have yet to find that.

There is a way to test though. You could go get regmon from sysinternals and run it on one of your servers. Then, change that server from one mode to another. You could then see exactly what changes in the registry when it switches modes. Then you can edit the script accordingly. Either script would work for that.
 
ditech2k,

I have verified and compared the registry entries between a server with terminal server in the application server mode (with Citrix installed) and a server with terminal server in the remote administration mode (withot Citrix installed). Below are what I found:

TSAppCompat - exists in Windows Server 2003 and Windows 2000 Server:

REG_DWORD = 1 for terminal server in the application server mode, and REG_DWORD = 0 for terminal server in the remote administration mode.

TSAdvertise - exists in Windows Server 2003 only:

REG_DWORD = 1 for terminal server in the application server mode, and REG_DWORD = 0 for terminal server in the remote administration mode.

TSUserEnabled - exists in Windows Server 2003 and Windows 2000 Server:

REG_DWORD = 0 for terminal server in the application server mode, and REG_DWORD = 0 for terminal server in the remote administration mode.

Therefore, we can conclude that either of the first two entries above will work for Windows Server 2003. Only the first entry can be used for both Windows Server 2003 and Windows 2000 Server.

The last entry does not provide any distinction between the two types of servers.

Thanks for checking anyway!

CluM09
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top