distinguish between server os and workstation

  • Thread starter Thread starter Dennis C. Drumm
  • Start date Start date
D

Dennis C. Drumm

How can I tell programmatically if an application is running on a server or
workstation, e.g. windows 2000 server or windows 2000 professional for
example?

Thanks,

Dennis
 
Hi Dennis,

As far as I know, we can check the version of the operating system to
distinguish whether it is on a server os or a workstation os.
System.Environment.OSVersion property is designed to do this. Please check
the following link for more information.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemenvironmentclassosversiontopic.asp

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
How can I tell programmatically if an application is running on a server or
workstation, e.g. windows 2000 server or windows 2000 professional for
example?

Call GetVersionEx with the OSVERSIONINFOEX struct, then check whether
the wProductType member has the VER_NT_SERVER or VER_NT_WORKSTATION
flag set. See

http://support.microsoft.com/?kbid=304721
http://msdn.microsoft.com/library/en-us/sysinfo/base/getversionex.asp

An alternative is to use WMI, the Win32_OperatingSystem class and its
ProductType property.



Mattias
 
Kevin:

The platform name and the major, minor and build numbers are the same for
both the server and workstation. For windows 2000 both are Win32NT platforms
and both share the same version number, 5.0.2195. The build number is based
in part (I think) upon the service pack installed. So there must be some
other distinguishing identifier between the two?

Thanks,

Dennis
 
Thanks Mattias,

Is there any way this can be done without using InteropServices?

Thanks,

Dennis
 
Is there any way this can be done without using InteropServices?

Yes, as I said you can use WMI (System.Management).




Mattias
 
Mattias:

I see now that WMI is a managed class. I am trying to figure out how to use
it.

Thanks for the info,

Dennis
 
Mattias:

from testing and the documentation, it seems that WinNT and Win2K does not
support the ProductType property.

Does this square with you understanding of this class?

If so, do you know of some other way to use someting in WMI to destinguish
server from workstation?

Thanks,

Dennis
 
Hi Dennis,

After checking the OSVersion, we make sure that this is a Windows 2000 OS,
we can use a registry key to distinguish the server/pro version of Windows
2000.

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

WinNT stands for Pro, while ServerNT stands for Server.

HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
You're welcome, Dennis.

Thanks for sharing your experience with all the people here. If you have
any questions, please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 
Back
Top