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 setlocal 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 :Syntax @echo Syntax: call TermSrv \\ComputerName TSE If \{%2\}
\{\} endlocal&goto :EOF endlocal&set %2=E