|
Each contribution is licensed to you under a License Agreement by its owner, not Microsoft. Microsoft does not guarantee the contribution or purport to grant rights to it.
|
Categories |
Check the Version Number of a File(Community)
Script Code
VBScript
'==========================================================================
'
' VBScript Source File -- Created with SAPIEN Technologies PrimalSCRIPT(TM)
'
' NAME: filever.vbs
'
' AUTHOR: Sean Rooney
' DATE : 16/06/2005
'
' COMMENT: Check the file version for a particular file
'
'==========================================================================
arrayComputers = Array("server1","server2","server3")
For Each strServer in arrayComputers
If Not Reachable(strserver) Then
Wscript.Echo(strServer & ", Server Not Available")
Else
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strServer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("Select * from CIM_Datafile Where name = 'c:\\winnt\\system32\\ntfrs.exe'")
For Each objFile in colFiles
Wscript.Echo strServer & ", Version: " & objFile.Version
Next
End If
Next
Function Reachable(HostName)
Dim wshShell, fso, tfolder, tname, TempFile, results, retString, ts
Const ForReading = 1, TemporaryFolder = 2
Reachable = false
Set wshShell = wscript.createobject("wscript.shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set tfolder = fso.GetSpecialFolder(TemporaryFolder)
tname = fso.GetTempName
TempFile = tfolder & tname
wshShell.run "cmd /c ping -n 3 -w 1000 " & HostName & ">" & TempFile,0,true
Set results = fso.GetFile(TempFile)
Set ts = results.OpenAsTextStream(ForReading)
Do While ts.AtEndOfStream <> True
retString = ts.ReadLine
If instr(retString, "Reply") > 0 Then
Reachable = true
Exit Do
End If
Loop
ts.Close
results.delete
Set ts = Nothing
Set results = Nothing
Set tfolder = Nothing
Set fso = Nothing
Set wshShell = Nothing
End Function
Platforms
For online peer support, join
The Official Scripting Guys Forum!
To provide feedback or report bugs in sample scripts, please start a new discussion on the Discussions tab for this script.
Disclaimer
The sample scripts are not supported under any Microsoft standard support program or service. The sample scripts are provided AS IS without warranty of any kind. Microsoft further disclaims all implied warranties including, without limitation, any implied warranties of merchantability or of fitness for a particular purpose. The entire risk arising out of the use or performance of the sample scripts and documentation remains with you. In no event shall Microsoft, its authors, or anyone else involved in the creation, production, or delivery of the scripts be liable for any damages whatsoever (including, without limitation, damages for loss of business profits, business interruption, loss of business information, or other pecuniary loss) arising out of the use of or inability to use the sample scripts or documentation, even if Microsoft has been advised of the possibility of such damages.
|