How to Retrieve a File's “Product Version” in VBScript

前端 未结 5 801
你的背包
你的背包 2020-12-16 20:25

I have a VBScript that checks for the existence of a file in a directory on a remote machine. I am looking to retrieve the \"Product Version\" for said fil

5条回答
  •  时光说笑
    2020-12-16 21:07

    You can use the Shell.Namespace to get the extended properties on a file, one of which is the Product Version. The GetDetailsOf function should work. You can test with the following code to get an idea:

    Dim fillAttributes(300)
    
    Set shell = CreateObject("Shell.Application")
    Set folder = shell.Namespace("C:\Windows")
    
    Set file = folder.ParseName("notepad.exe")
    
    For i = 0 to 299
        Wscript.Echo i & vbtab & fillAttributes(i) _
            & ": " & folder.GetDetailsOf(file, i) 
    Next
    

    One thing to be aware of:

    The extended properties of a file differs between versions of Windows. Hence, the product version index numbers changes based on the version of Windows you are using. You can use the code above to determine what they are. From my testing, I believe they are as follows:

    • Window XP - 39
    • Windows Vista - 252
    • Windows 7 - 268
    • Windows 2008 R2 SP1 - 271
    • Windows 2012 R2 - 285

    You may also find the following post helpful.

提交回复
热议问题