Option Explicit On Error Resume Next Dim drive, fso, SAVDef, SAVDir1, SAVDir2, SAVDir3, SAVVer, strComputer, strMsg strMsg = vbCrLf ' Parse command line If WScript.Arguments.Named.Count > 0 Then Syntax If WScript.Arguments.UnNamed.Count > 1 Then Syntax If WScript.Arguments.UnNamed.Count = 1 Then If Ping( WScript.Arguments.UnNamed(0) ) Then strComputer = GetComputerName( WScript.Arguments.UnNamed(0) ) drive = "\\" & strComputer & "\C$" Else strMsg = strMsg & WScript.Arguments.UnNamed(0) & " is off-line" & vbCrLf & vbCrLf Syntax End If Else drive = "C:" strComputer = GetComputerName( "." ) End If ' Specify file locations SAVDir1 = drive & "\Program Files\SAV" SAVDir2 = drive & "\Program Files\Symantec AntiVirus" SAVDir3 = drive & "\Program Files\Common Files\Symantec Shared\VirusDefs" ' Create file system object Set fso = CreateObject( "Scripting.FileSystemObject" ) ' Retrieve program file version info SAVVer = fso.GetFileVersion( SAVDir1 & "\Rtvscan.exe" ) & fso.GetFileVersion( SAVDir2 & "\Rtvscan.exe" ) ' Retrieve definitions file version info SAVDef = ReadINI( SAVDir3 & "\definfo.dat", "DefDates", "CurDefs" ) ' Display the result strMsg = strMsg _ & "Computer Name : " & strComputer & vbCrLf _ & "Symantec AntiVirus version : " & SAVVer & vbCrLf _ & "Virus definitions : " & SAVDef & vbCrLf WScript.Echo strMsg ' Get local computer name Function GetComputerName( strHost ) Dim colItems, objItem, objWMIService Set objWMIService = GetObject( "winmgmts://" & strHost & "/root/cimv2" ) Set colItems = objWMIService.ExecQuery( "Select * from Win32_ComputerSystem", , 48 ) For Each objItem in colItems GetComputerName = objItem.Name Next End Function ' Function to ping a specified host and returns boolean TRUE if it is contactable and FALSE if not Function Ping( strHost ) ' On Error Resume Next Dim objPing : Set objPing = Nothing ' The Win32_PingStatus WMI object Dim objStatus : Set objStatus = Nothing ' The result of the Win32_PingStatus WMI object ' Creates the ping object specifying the host to ping Set objPing = GetObject( "winmgmts:{impersonationLevel=impersonate}" ).ExecQuery( "SELECT * FROM Win32_PingStatus WHERE address = '" & strHost & "'" ) ' Check the status of each ping response For Each objStatus In objPing ' If the status code is Null or Not 0 then the ping failed If IsNull( objStatus.StatusCode ) Or objStatus.StatusCode <> 0 Then ' Set the function to return Boolean FALSE Ping = False Else ' Set the function to return Boolean TRUE Ping = True End If Next End Function Function ReadINI( ini, section, key ) 'Initialize variables and constants Dim handle, keyfound, line, lineArray, linekey, lineval, objFso, sect, sectfound Const ForReading = 1 sectfound = False sect = "[" & Strip( section ) & "]" keyfound = False ReadINI = "" 'Open INI file in read-only mode Set objFso = CreateObject( "Scripting.FileSystemObject" ) Set handle = objFso.OpenTextFile( ini, ForReading ) 'Search the INI file for the specified key in the specified section Do While handle.AtEndOfStream <> True And keyfound = False line = Strip( handle.ReadLine ) If Left( line, 1 ) = "[" Then If StrComp( line, sect, vbTextCompare ) = 0 Then sectfound = True Else sectfound = False End If Else If sectfound Then If InStr( 1, line, "=", vbTextCompare ) > 0 Then lineArray = Split( line, "=", 2, vbTextCompare ) linekey = Strip( lineArray(0) ) lineval = Strip( lineArray(1) ) If StrComp( linekey, key, vbTextCompare ) = 0 Then ReadINI = lineval keyfound = True End If End If End If End If Loop 'Close the file handle.close End Function 'Strip leading and trailing whitespace and quotes from a string Function Strip( mystring ) Do While Left( mystring, 1 ) = " " Or Left( mystring, 1 ) = Chr(9) mystring = Mid( mystring, 2 ) Loop Do While Right( mystring, 1 ) = " " Or Right( mystring, 1 ) = Chr(9) mystring = Mid( mystring, 1, Len( mystring ) - 1 ) Loop If Left( mystring, 1 ) = Chr(34) Then mystring = Mid( mystring, 2 ) End If If Right( mystring, 1 ) = Chr(34) Then mystring = Mid( mystring, 1, Len( mystring ) - 1 ) End If Strip = mystring End Function Sub Syntax strMsg = vbCrLf _ & "SAVVer.vbs, Version 1.00" & vbCrLf _ & "Display Symantec AntiVirus program and definitions version" & vbCrLf & vbCrLf _ & "Usage: [ CSCRIPT ] SAVVER.VBS [ host ]" & vbCrLf & vbCrLf _ & "Where: " & Chr(34) & "host" & Chr(34) _ & " is a remote computer's name or IP address" & vbCrLf _ & " (default is the local computer)" & vbCrLf & vbCrLf _ & "Written by Rob van der Woude" & vbCrLf _ & "http://www.robvanderwoude.com" WScript.Echo strMsg WScript.Quit(1) End Sub