From: Michael Brednich Michael on
Is it possible to programmatically check whether a Windows Server 2008 has
the role "terminal services"?

VerifyVersionInfo always returns true when checking VER_SUITE_TERMINAL, no
matter if the role ist set or not.

With Windows server 2003 I used to look up "fDenyTSConnections" in
"HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server", but with server 2008
the role "terminal service" has no influence on this key.

I've also tried to access the IWbemServices and enumerate through "SELECT *
FROM Win32_TerminalServiceSetting", but this did not work either.

Any other possibilities?

Thanks,
Michael
From: Vera Noest on
Check this:

How can my script / application detect if a Windows 2008 server is
configured for Remote Administration or running the Terminal Server
role service?
http://ts.veranoest.net/ts_faq_administration.htm#TSversusAdminmode
_2008

_________________________________________________________
Vera Noest
Remote Desktop Services troubleshooting
http://ts.veranoest.net

=?Utf-8?B?TWljaGFlbCBCcmVkbmljaA==?= <Michael
Brednich(a)discussions.microsoft.com> wrote on 06 maj 2010:

> Is it possible to programmatically check whether a Windows
> Server 2008 has the role "terminal services"?
>
> VerifyVersionInfo always returns true when checking
> VER_SUITE_TERMINAL, no matter if the role ist set or not.
>
> With Windows server 2003 I used to look up "fDenyTSConnections"
> in "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server", but
> with server 2008 the role "terminal service" has no influence on
> this key.
>
> I've also tried to access the IWbemServices and enumerate
> through "SELECT * FROM Win32_TerminalServiceSetting", but this
> did not work either.
>
> Any other possibilities?
>
> Thanks,
> Michael
From: Shagun Sharma Tamta [MSFT] on
One solution to this can be enumerating instances of
win32_tssessiondirectory class. If the Terminal server role service is not
installed then this should not return any instances. But when it is
installed, this class is used to do configuration related to session
directory.
Same is applicable even for Win2k8 R2.

Thanks,
Shagun

"Michael Brednich" <Michael Brednich(a)discussions.microsoft.com> wrote in
message news:4F6DE877-641E-4BAB-B507-C3331B044AD0(a)microsoft.com...
> Is it possible to programmatically check whether a Windows Server 2008 has
> the role "terminal services"?
>
> VerifyVersionInfo always returns true when checking VER_SUITE_TERMINAL, no
> matter if the role ist set or not.
>
> With Windows server 2003 I used to look up "fDenyTSConnections" in
> "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server", but with server
> 2008
> the role "terminal service" has no influence on this key.
>
> I've also tried to access the IWbemServices and enumerate through "SELECT
> *
> FROM Win32_TerminalServiceSetting", but this did not work either.
>
> Any other possibilities?
>
> Thanks,
> Michael

From: Michael Brednich on
Thanks Shagun and Vera,

I'v tried your suggestions but they both don't work. Here's my test script:

On Error Resume Next

Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20

Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")

' Shagun: enumerating Win32_TSSessionDirectory
Set colItems = objWMIService.ExecQuery("SELECT * FROM
Win32_TSSessionDirectory", "WQL", _
wbemFlagReturnImmediately +
wbemFlagForwardOnly)
WScript.Echo "ExecQuery Win32_TSSessionDirectory done"

For Each objItem In colItems
WScript.Echo "Caption: " & objItem.Caption
Next

' Vera: enumerating Win32_TerminalServiceSetting
Set colItems = objWMIService.ExecQuery("SELECT * FROM
Win32_TerminalServiceSetting", "WQL", _
wbemFlagReturnImmediately +
wbemFlagForwardOnly)
WScript.Echo "ExecQuery Win32_TerminalServiceSetting done"

For Each objItem In colItems
WScript.Echo "AllowTSConnections: " & objItem.AllowTSConnections
Next


In both cases ExecQuery for Win32_TSSessionDirectory and
Win32_TerminalServiceSetting returns no items, no matter whether the terminal
server role is installed or not.

Am I doing anything wrong with this script? Or do you have another suggestion?

Thanks,
Michael
From: TP on
Hi Michael,

You can use WMI to query whether or not specific Roles/Role Services
are installed. For example, to determine if the Terminal Server
(Remote Desktop Session Host on R2) Role Service is installed, you
can use the following query via the command line:

wmic /namespace:\\root\CIMV2 PATH Win32_ServerFeature WHERE (ID=130)

As an experiment, remove "WHERE (ID=130)" to get a list of all installed
features.

Now all you need to do is convert the above wmic command to the
equivalent in your programming/scripting language of choice.

Thanks.

-TP

Michael Brednich wrote:
> Is it possible to programmatically check whether a Windows Server
> 2008 has the role "terminal services"?
>
> VerifyVersionInfo always returns true when checking
> VER_SUITE_TERMINAL, no matter if the role ist set or not.
>
> With Windows server 2003 I used to look up "fDenyTSConnections" in
> "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server", but with
> server 2008 the role "terminal service" has no influence on this key.
>
> I've also tried to access the IWbemServices and enumerate through
> "SELECT * FROM Win32_TerminalServiceSetting", but this did not work
> either.
>
> Any other possibilities?
>
> Thanks,
> Michael