JSI Tip 7459. How can I determine if Terminal Services is enabled on a local or remote server?

Jerold Schulman

November 17, 2003

1 Min Read
ITPro Today logo in a gray background | ITPro Today

If Terminal Services is enabled on a server, the value of TSEnabled, a REG_DWORD data type, at HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlTerminal 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 offsetlocalIf {%2}
{} goto syntaxset computer=%1set computer=\%computer:=%if not exist %computer%c$ goto syntaxset key="%computer%HKLMSYSTEMCurrentControlSetControlTerminal Server"for /f "Skip=4 Tokens=1,3" %%i in ('reg QUERY %key% /v TSEnabled') do if /i "%%i" EQU "TSEnabled" set TSEV=%%jif not defined TSEV goto syntaxset TSE=Nif "%TSEV%" EQU "0x1" set TSE=Yendlocal&set %2=%TSE%goto :EOF:Syntax@echo Syntax: call TermSrv \ComputerName TSEIf {%2}
{} endlocal&goto :EOFendlocal&set %2=E



Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like