Find OS name / version using JScript

I need to maintain a server-side script written in JScript (NOT Javascript) that should detect the OS of the system it is running on. How can I do this correctly and reliably?

+1


source to share


1 answer


Take a look here for all the system information you can get.

Here is some sample code I put together based on this web page:



var wbemFlagReturnImmediately = 0x10;
var wbemFlagForwardOnly = 0x20;
var objWMIService = GetObject("winmgmts:\\\\.\\root\\CIMV2");
var colItems = objWMIService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL",
                                      wbemFlagReturnImmediately | wbemFlagForwardOnly);

var enumItems = new Enumerator(colItems);
var objItem = enumItems.item();
WScript.Echo("Caption: " + objItem.Caption);

      

+5


source







All Articles