vbscript - Checking OS version -


Hello I'm having trouble understanding this code. Can anyone explain to me what does this do?

  GetOperatingSystemVersion if OSVersion & gt; 6.0 then strCMD = "c: \ Windows \ System32 \ manage-bde.exe" otherwise the strCMD = "cscript.exe c: \ Windows \ System32 \ manage-bde.wsf" if the end gets' sub GetOperatingSystemVersion set objWMIService = GetObject ("Winmgmts: {impersonation level = impersonation}! \\. \ Root \ cimv2") set oss = objWMIService.ExecQuery ("Choose Win32_OperatingSystem * from") OS OSVersion = OS = Left in each (OS version, 3) OSVersion = Round (OSVersion, 3) Next End Sub   

In my opinion, it will call GetOperatingSystemVersion and will check for loop. This is the part that I could not understand thanks in advance :)

Actually, this operating system version Uses to retrieve

The first two lines are only standard WMI-to-VBScript idioms. If you run a keyword search, you will find a lot of sample code and information on this online. The important part is Win32_OperatingSystem , which specifies the WMI class for that query. Plug that code into MSDN, you will get a list of the properties and methods that will be revealed by that class.

By putting it together, then, syntax select from Win32_OperatingSystem is a question that receives all the examples of the Win32_OperatingSystem class, including all members of that class is.

In each archive returned for each loop loops, one at a time. For the Win32_OperatingSystem class, it is not strictly necessary, because only one global object should be returned. But VBSScript (at least before Vista) had no way of accessing a particular item in a collection, so you had to do this.

for each code> loop, OS refers to an instance of the object variable Win32_OperatingSystem class , Which states that a version reveals a member, which gives a return string. This member is inquired, and the left function removes 3 characters before his left hand. These 3 characters are stored in the OSVersion variable.

This is necessary because the modern version of Windows includes the build number as part of the version number, which results in some string like 6.1.7601 or 5.1.2600 . The code using the version number apparently does not care about the build number; It only wants the number of major and minor versions, so it only removes the first 3 characters in the version field.

Finally, 3 digits stored in the OSVersion variable, 3 decimal places using the goals function, and the result OSVersion Back in the variable as it only removes the first 3 characters in the version field, so I do not know why it is doing this.

So when the function ends, the current version of the OSVersion variable is the operating system, round at 3 decimal places. The code is fragile, though, and should be maintained with caution. What happens when Microsoft version releases a version of Microsoft Windows with version 6.10.xxxx ? (Answer: This code is called version 6.1 .)

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -