I am creating a script that I want to run at logon in a Windows NT
domain, but want it to execute on Windows 2000 or XP Professional
Workstations only, not on Servers. We have several admins that use the
same username to log on to both their workstations, and servers,
creating issues if the same script executes when they log on to their
servers.

While I am able to use the System environment variable to determine
that the OS is Windows_NT, and use a subsequent registry read of
HKLM\Software\Windows NT\CurrentControlSet\CurrentControlSet to
determine the OS version as 5.0 or 5.1. This doesn't tell me whether
the machine is XP/2000 professional, or server 2000/2003.

This sounds real easy, but I have been researching this, and, as of
yet, have been unable to locate an efficient way to tell whether the
local machine is a workstation or server. Do you have any suggestions
that will work in a large environment (10000 + workstations and
servers)?

Re: Run Logon Script on Workstations Only by Ele7eN

Ele7eN
Tue Nov 29 12:30:57 CST 2005

You can just look for the word "server" in the OS caption. Here's how
I do it:

set colOS =
GetObject("winmgmts:root\cimv2").InstancesOf("Win32_OperatingSystem")
for each objOS in colOS
strOperatingSystem = objOS.Caption
next

if isWorkstation(strOperatingSystem) then
End if

function isWorkstation (strOS)
if InStr(strOS, "Server") = 0 then
isWorkstation = true
else
isWorkstation = false
end if
end function


Re: Run Logon Script on Workstations Only by James

James
Tue Nov 29 13:23:02 CST 2005

"DM" <jgeorge@isd.sbcounty.gov> wrote in message
news:1133287517.439613.242990@o13g2000cwo.googlegroups.com...
> I am creating a script that I want to run at logon in a Windows NT
> domain, but want it to execute on Windows 2000 or XP Professional
> Workstations only, not on Servers. We have several admins that use the
> same username to log on to both their workstations, and servers,
> creating issues if the same script executes when they log on to their
> servers.

I have two suggestions. #1, look at this registry key (watch for
wrapping):

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions\ProductTy
pe

On the Windows 2000 Pro and XP Pro this should have a value of "WinNT" on
the servers, it will have a value of "ServerNT" or "LanmanNT". See this
article: http://support.microsoft.com/kb/q152078/

Or, #2, you could check the 'DomainRole' from WMI. See this article:
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_computersystem.asp

Here is a small example using 'RegRead' (watch for wrapping):

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim oWSH, sProductType
Set oWSH = CreateObject("WScript.Shell")
sProductType =
oWSH.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\ProductOptions\ProductTy
pe")
If sProductType <> "WinNT" Then WScript.Quit
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Here is an example using WMI (watch for wrapping):

'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dim x
For Each x in
GetObject("winmgmts:\\.\root\cimv2").InstancesOf("Win32_ComputerSystem")
If x.DomainRole > 1 Then WScript.Quit
Next
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I have not actually conducted any tests, but I would bet that reading the
registry key would be faster.



Re: Run Logon Script on Workstations Only by maximillianx

maximillianx
Tue Nov 29 13:27:06 CST 2005

If you prefer to stick with command line utilities, you can use Bill
Stewart's OSVer tool. This command-line program will output the OS version.
You could then capture the output and perform actions based upon the OS
version installed.

http://internet.cybermesa.com/~bstewart/wast.html

Rob

"DM" <jgeorge@isd.sbcounty.gov> wrote in message
news:1133287517.439613.242990@o13g2000cwo.googlegroups.com...
>I am creating a script that I want to run at logon in a Windows NT
> domain, but want it to execute on Windows 2000 or XP Professional
> Workstations only, not on Servers. We have several admins that use the
> same username to log on to both their workstations, and servers,
> creating issues if the same script executes when they log on to their
> servers.
>
> While I am able to use the System environment variable to determine
> that the OS is Windows_NT, and use a subsequent registry read of
> HKLM\Software\Windows NT\CurrentControlSet\CurrentControlSet to
> determine the OS version as 5.0 or 5.1. This doesn't tell me whether
> the machine is XP/2000 professional, or server 2000/2003.
>
> This sounds real easy, but I have been researching this, and, as of
> yet, have been unable to locate an efficient way to tell whether the
> local machine is a workstation or server. Do you have any suggestions
> that will work in a large environment (10000 + workstations and
> servers)?
>



Re: Run Logon Script on Workstations Only by DM

DM
Tue Nov 29 13:53:43 CST 2005

Thank you for the suggestion. I used the ProductType method
successfully.