I am trying to find a way to see if a compiled script is running on a server or not.
I have tried using %OS_SYS%, but it comes up as follows:
On Server 2003
NT.5.2.3790
On Vista
NT.6.0.6002
So both of them have NT, and version numbers, but how to tell if it is a version on a server as opposed to a workstation.
How to determine Operationg System
Moderators: Dorian (MJT support), JRL
Re: How to determine Operationg System
systeminfo in command prompt retrieves the OS Configuration amongst other things.
Code: Select all
Let>RP_WAIT=1
Let>RP_WINDOWMODE=0
Del>%TEMP_DIR%SystemInfo.txt
Run>cmd /c systeminfo > %TEMP_DIR%SystemInfo.txt
ReadFile>%TEMP_DIR%SystemInfo.txt,System_Info
mdl>System_Info
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
The info is in the Registry:
HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows NT\CurrentVersion
There are several entries that may have what you need, ProductName returns e.g. Microsoft Windows 7 Professional, there is also InstallationType which is Client on my laptop and I believe will return Server for a server OS - but I have no way to test that right now.
HKEY_LOCAL_MACHINE,SOFTWARE\Microsoft\Windows NT\CurrentVersion
There are several entries that may have what you need, ProductName returns e.g. Microsoft Windows 7 Professional, there is also InstallationType which is Client on my laptop and I believe will return Server for a server OS - but I have no way to test that right now.
Code: Select all
VBSTART
On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("SELECT ProductType FROM Win32_OperatingSystem", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
intProdType = objItem.ProductType
Next
VBEND
VBEval>intProdType,intProdType
If>%intProdType%=1
MDL>Work Station
EndIf
If>{(%intProdType%=2) OR (%intProdType%=3)}
MDL>Server
EndIf