1.    30 Jul 2008 #1
    tke402 Guest

    Script to retrieve file versions


    hi,

    I found this script on Scripting Guy. However I would like for the window to
    have the results of three file versions. Here's what I have now. It shows in
    three seperate windows one at a time:

    strComputer = "Server1"

    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

    Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_Datafile Where Name =
    'c:\\windows\\system32\\setup.exe'")

    For Each objFile in colFiles
    Wscript.Echo objFile.Version
    Next

    strComputer = "Server2"

    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

    Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_Datafile Where Name =
    'c:\\windows\\system32\\setup.exe'")

    For Each objFile in colFiles
    Wscript.Echo objFile.Version
    Next

    strComputer = "Server3"

    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

    Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_Datafile Where Name =
    'c:\\windows\\system32\\setup.exe'")

    For Each objFile in colFiles
    Wscript.Echo objFile.Version
    Next


      My System SpecsSystem Spec

  2.    30 Jul 2008 #2
    mayayana Guest

    Re: Script to retrieve file versions


    Did you know that you don't need WMI for that?
    (Unless there's a problem using FSO across a network.
    I've never tried that.)

    -------------------
    Set FSO = CreateObject("Scripting.FileSystemObject")
    S = FSO.GetFileVersion("c:\windows\system32\setup.exe")
    -------------------

    If you want to show it all in one msgbox you can
    use a variable to concatenate the values as you collect
    them. Instead of using WScript.echo with each machine,
    you can do something like this:

    Dim sVer

    Set colFiles = objWMIService.ExecQuery _
    ("Select * from CIM_Datafile Where Name =
    'c:\\windows\\system32\\setup.exe'")

    For Each objFile in colFiles
    sVer = sVer & strComputer & " - " & objFile.Version & vbcrlf
    Next

    Do the same for each machine. Then at the end
    you can show one window with:

    MsgBox sVer

    The window will show a list like:

    Server1 - 1.055
    Server2 - 1.055
    Server3 - 1.061


    >
    > I found this script on Scripting Guy. However I would like for the window
    to

    > have the results of three file versions. Here's what I have now. It shows
    in

    > three seperate windows one at a time:
    >
    > strComputer = "Server1"
    >
    > Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    >
    > Set colFiles = objWMIService.ExecQuery _
    > ("Select * from CIM_Datafile Where Name =
    > 'c:\\windows\\system32\\setup.exe'")
    >
    > For Each objFile in colFiles
    > Wscript.Echo objFile.Version
    > Next
    >
    > strComputer = "Server2"
    >
    > Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    >
    > Set colFiles = objWMIService.ExecQuery _
    > ("Select * from CIM_Datafile Where Name =
    > 'c:\\windows\\system32\\setup.exe'")
    >
    > For Each objFile in colFiles
    > Wscript.Echo objFile.Version
    > Next
    >
    > strComputer = "Server3"
    >
    > Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
    >
    > Set colFiles = objWMIService.ExecQuery _
    > ("Select * from CIM_Datafile Where Name =
    > 'c:\\windows\\system32\\setup.exe'")
    >
    > For Each objFile in colFiles
    > Wscript.Echo objFile.Version
    > Next
    >
    >

      My System SpecsSystem Spec


Similar Threads
Thread Forum
How to retrieve the script name inside Powershell?
$args contains the passing arguements, but no script name. How to get the script name inside itself in Powershell? Thanks!
PowerShell
how to test a script for compatibility with different Windows Versions
Hi, is there a way to test a VBS script (that uses lots of WMI functions) for compatibility with Win2000,XP,Vista,Win2003,Win2007 ...? The...
VB Script
Retrieve file from Recycle Bin issue
Hello, I am running Windows Vista Ultimate 64 bit, and yesterday, when I started my PC up, I was presented with a scaled down version of my...
General Discussion
problem passing args to script 'There is no script engine for file extenstion'
Hello, I'm having an issue passing args to a script. I'm getting the error 'There is no script engine for file extenstion .net' I assume the...
VB Script
How to retrieve the latest file
hi, I need to retrieve the latest file in a directory in powershell. Does anybody knows how to do this. Thanks, Aditya
PowerShell
Retrieve the path of the file
Hi, I have a requirement where in I know the name of the file. But do not know the complete path of its location. Moreover the machine will be...
PowerShell
Retrieve file version information
Hi, Here's my scenario: I need to retrieve file version information from three different servers. The file name is the same. For example...
PowerShell

Our Sites
  • Ten Forums
  • Eight Forums
  • Seven Forums
  • PC Help Forum
  • Help Me Bake
  • Site Links
  • Contact Us
  • Privacy and Cookies
  • About Us
    Windows Vista Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

    Designer Media Ltd
    All times are GMT -5. The time now is 01:09.
    .