Get Windows service pack level using VBA

Hi,

After a lot googling, I have found a couple of procs for to get Windows name, version and build. A few include service pack level but I have, so far, not been able to get the service pack level to work. The code looks like this,

Public Function WinVersionInfo()

    Dim SysReport As String, tmp As String
    Dim objWMIService As Object 'Variant
    Dim colOperatingSystems As Object
    Dim objOperatingSystem As Object
   
    Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & ".\root\cimv2")
    Set colOperatingSystems = objWMIService.ExecQuery("Select * from Win32_OperatingSystem")
   
    For Each objOperatingSystem In colOperatingSystems
       
         SysReport = SysReport & Trim(objOperatingSystem.Caption) & " SP " & objOperatingSystem.szCSDVersion & " (" & objOperatingSystem.Version & ")"
    Next
    WinVersionInfo = SysReport

End Function

It would not accept the szCSDVersion above, why? what is wrong? As you can see it is VBA used for a Access 2003 application.

Thanks in advance

B Anders
BAndersConsultantAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kanti PrasadCommented:
Hi

Try this

objOperatingSystem.ServicePackMajorVersion
objOperatingSystem.ServicePackMinorVersion
BAndersConsultantAuthor Commented:
Hi,

Well, I have seen that before, but that means I would have to do something like this as for Access

        Case "14.0.7015.1000" To "14.0.9999.9999": GetAccessVersion = "Microsoft Access 2010 SP2 (" & sAccessVerNo & ")"

That means I need to found the same build version number as for Access. So far I haven't found them.

According to some articles the szCSDVersion property should contain SP data, actually if SP installed or which level. The WMIService object seems not containing the szCSDVersion property, still people is saying it shall. The structure OSVERSIONINFO contains but doesn't work either.

The solution I look for must work for both 32 and 64 bits versions of Windows. On the PC I develop, that one is on SP 1.


BAnders
Kanti PrasadCommented:
Hi

I am not sure if the below link will help, but it is looking for  windows  versions


http://www.developerfusion.com/code/1643/windows-version-information/

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BAndersConsultantAuthor Commented:
Hi,
 
Back from holidays, I avoid Internet on holidays.

What I have to do is to combine a number of ways for to get what I want to have. No single solution this time.

Thanks anyway
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.