If Terminal Services is enabled on a server, the value of TSEnabled, a REG_DWORD data type, at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server in the server's registry, is set to 1 (0x1).

Using REG.EXE on Windows 2000, from the Windows 2000 Support Tools, or REG.EXE built into later operating systems, I have scripted TermSrv.bat to determine if Terminal Services is enabled on a local or remote server.

The syntax for using TermSrv.bat is:

call TermSrv ComputerName TSE

where ComputerName is the NetBIOS name of the local or remote server, with or without a leading \\, and TSE is a call directed environment variable that will be set to a Y if Terminal Services is enabled, a N if Terminal Services is NOT enabled, and an E if an error has occurred.

TermSrv.bat contains:

@echo off
If \{%2\}<h1><a name="_goto_syntax_set_computer_1_set_computer_computer_if_not_exist_computer_c_goto_syntax_set_key_computer_HKLM_SYSTEM_CurrentControlSet_Control_Terminal_Server_for_f_Skip_4_Tokens_1_3_i_in_reg_QUERY_key_v_TSEnabled_do_if_i_i_EQU_TSEnabled_set_TSEV_j_if_not_defined_TSEV_goto_syntax_set_TSE_N_if_TSEV_EQU_0x1_set_TSE_Y_endlocal_amp_set_2_TSE_goto_EOF_Syntax_echo_Syntax_call_TermSrv_ComputerName_TSE_If_2_">\{\} goto syntax
set computer=%1
set computer=\\%computer:\=%
if not exist %computer%\c$ goto syntax
set key="%computer%\HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server"
for /f "Skip=4 Tokens=1,3" %%i in ('reg QUERY %key% /v TSEnabled') do if /i "%%i" EQU "TSEnabled" set TSEV=%%j
if not defined TSEV goto syntax
set TSE=N
if "%TSEV%" EQU "0x1" set TSE=Y
endlocal&set %2=%TSE%
goto :EOF
@echo Syntax: call TermSrv \\ComputerName TSE
If \{%2\}</a></h1>\{\} endlocal&goto :EOF
endlocal&set %2=E