SubSun
asked on
Error with VB Script
The attached code for reporting the antivirus status of multiple computers works fine with my windows XP (SP3) machines but not with the windows server 2003 (SP2). Please check and tell me what is wrong and help me to correct the issue. Thanks in advance.
I am getting error: - av.vbs(11, 2) (null): 0x8004100E
I am getting error: - av.vbs(11, 2) (null): 0x8004100E
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Set fso = CreateObject("Scripting.FileSystemObject")
Set objInputFile = fso.OpenTextFile("server.txt", 1, True)
Set ObjOutputFile = fso.OpenTextFile("Results.txt", 2, True)
Do While objInputFile.AtEndOfLine <> True
strComputer = objInputFile.Readline
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\SecurityCenter")
Set colItems = objWMIService.ExecQuery("SELECT * FROM antivirusProduct", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
ObjOutputFile.WriteLine ("Server : " & strComputer)
ObjOutputFile.WriteLine ("DisplayName : " & objItem.DisplayName)
ObjOutputFile.WriteLine ("OnAccessScanningEnabled : " & objItem.OnAccessScanningEnabled)
ObjOutputFile.WriteLine ("productUptoDate : " & objItem.productUptoDate)
ObjOutputFile.WriteLine ("VersionNumber : " & objItem.VersionNumber)
ObjOutputFile.WriteLine ("--------------------------------------------------------")
Next
Loop
objOutputFile.Close
Set objOutputFile = fso.openTextFile("Results.txt", 1,True)
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "admin@domain.com"
objEmail.To = "subsun@domain.com"
objEmail.Subject = "AV Report"
objEmail.TextBody = objOutputfile.ReadAll
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTP Relay"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
Do you have any blank lines in your text files?
Hi, the SecurityCenter namespace is not in Windows 2003. As far as I know, you'd have to read the relevant registry keys for you anti-virus product to gather that information.
Regards,
Rob.
Regards,
Rob.
ASKER
kaufmed: There is no blank line in text file. Also the script works perfectly with my windows XP machines, any more ideas would be appreciated.
RobSampson: I am using Symantec Endpoint Protection 11.0 for all servers and I would like to report the virus pattern version, updated date and status (enabled or disabled). Could you please help me to build a script? Please let me know if you need any further details. Thanks in advance.
RobSampson: I am using Symantec Endpoint Protection 11.0 for all servers and I would like to report the virus pattern version, updated date and status (enabled or disabled). Could you please help me to build a script? Please let me know if you need any further details. Thanks in advance.
Hmmm, if this WMI Update does not apply to your products:
http://service1.symantec.com/SUPPORT/sharedtech.nsf/0/c2418ae9dd4f5dad88256ecb006a1503?OpenDocument&seg=hm&lg=en&ct=us
then you'll have to stick to reading the registry I think.
For Symantec products, some likely registry keys might be:
HKLM\SOFTWARE\Symantec\Com mon Client
HKLM\SOFTWARE\Symantec\Sha redDefs
so try to fish around there on your server (it may be Software\Symantec Antivirus) and see if you can find likely values.
If you find those, we can build those into your script after having it determine whether the SecurityCenter namespace exists or not.
Regards,
Rob.
http://service1.symantec.com/SUPPORT/sharedtech.nsf/0/c2418ae9dd4f5dad88256ecb006a1503?OpenDocument&seg=hm&lg=en&ct=us
then you'll have to stick to reading the registry I think.
For Symantec products, some likely registry keys might be:
HKLM\SOFTWARE\Symantec\Com
HKLM\SOFTWARE\Symantec\Sha
so try to fish around there on your server (it may be Software\Symantec Antivirus) and see if you can find likely values.
If you find those, we can build those into your script after having it determine whether the SecurityCenter namespace exists or not.
Regards,
Rob.
ASKER
How to convert this registry values to readable string? Any idea?
This depends on what those values are...
Can you show me an example path and value from the key you're looking at? If the value is already in a REG_SZ format, we can easily read it using the StdRegProv object in VBScript, which reads registry values. The only type that we can't really read is a REG_BINARY value...
Regards,
Rob.
Can you show me an example path and value from the key you're looking at? If the value is already in a REG_SZ format, we can easily read it using the StdRegProv object in VBScript, which reads registry values. The only type that we can't really read is a REG_BINARY value...
Regards,
Rob.
ASKER
For Symantec AV 10.1.6.6000
Scan Engine 81.3.0.13
Virus definition file Version 5/22/2009 rev.2
I have attached the reg keys which I found in a server, but not able to identify which keys read the above values.
symantec.txt
Scan Engine 81.3.0.13
Virus definition file Version 5/22/2009 rev.2
I have attached the reg keys which I found in a server, but not able to identify which keys read the above values.
symantec.txt
Hmmm, the registry doesn't appear to help much with this product.....
It does appear, however, that you can get your VirusDef version by reading this registry key:
"NAVCORP_70"="C:\\PROGRA~1 \\COMMON~1 \\SYMANT~1 \\VIRUSD~1 \\20090522 .002"
and then getting the file version from that file specified.
Perhaps the other version information will need to be determined from the EXE files that correspond to the Antivirus program, and the Real Time Scan Engine.
In the code below, change the following two lines
strSymantecEXE = "C:\Program Files\Symantec Antivirus\SymantecAV.exe"
strScanEngineEXE = "C:\Program Files\Common Files\Symantec Shared\ScanEngine.exe"
to point to those two executables, from which we will read the version numbers.
See if that helps at all...
Regards,
Rob.
It does appear, however, that you can get your VirusDef version by reading this registry key:
"NAVCORP_70"="C:\\PROGRA~1
and then getting the file version from that file specified.
Perhaps the other version information will need to be determined from the EXE files that correspond to the Antivirus program, and the Real Time Scan Engine.
In the code below, change the following two lines
strSymantecEXE = "C:\Program Files\Symantec Antivirus\SymantecAV.exe"
strScanEngineEXE = "C:\Program Files\Common Files\Symantec Shared\ScanEngine.exe"
to point to those two executables, from which we will read the version numbers.
See if that helps at all...
Regards,
Rob.
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Const HKEY_LOCAL_MACHINE = &H80000002
Set fso = CreateObject("Scripting.FileSystemObject")
Set objInputFile = fso.OpenTextFile("server.txt", 1, True)
Set ObjOutputFile = fso.OpenTextFile("Results.txt", 2, True)
Do While objInputFile.AtEndOfLine <> True
strComputer = objInputFile.Readline
On Error Resume Next
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\SecurityCenter")
' If the SecurityCenter namespace is available, query it
If Err.Number = 0 Then
Set colItems = objWMIService.ExecQuery("SELECT * FROM antivirusProduct", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
ObjOutputFile.WriteLine ("Server : " & strComputer)
ObjOutputFile.WriteLine ("DisplayName : " & objItem.DisplayName)
ObjOutputFile.WriteLine ("OnAccessScanningEnabled : " & objItem.OnAccessScanningEnabled)
ObjOutputFile.WriteLine ("productUptoDate : " & objItem.productUptoDate)
ObjOutputFile.WriteLine ("VersionNumber : " & objItem.VersionNumber)
ObjOutputFile.WriteLine ("--------------------------------------------------------")
Next
' Otherwise if the SecurityCenter namespance is not available, we can try the registry for a known product
Else
strSymantecEXE = "C:\Program Files\Symantec Antivirus\SymantecAV.exe"
strScanEngineEXE = "C:\Program Files\Common Files\Symantec Shared\ScanEngine.exe"
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Symantec\SharedDefs\"
strValueName = "NAVCORP_70"
ObjOutputFile.WriteLine ("Server : " & strComputer)
intReturn = objReg.GetStringValue(HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strDefsFile)
If intReturn = 0 Then
ObjOutputFile.WriteLine ("DisplayName : Symantec Antivirus " & FSO.GetFileVersion(strSymantecEXE))
If fso.FileExists(strDefsFile) = True Then
ObjOutputFile.WriteLine ("Defs File : " & FSO.GetFileName(strDefsFile))
ObjOutputFile.WriteLine ("Defs Version : " & FSO.GetFileVersion(strDefsFile))
Else
ObjOutputFile.WriteLine ("Defs File : Cannot find " & strDefsFile)
ObjOutputFile.WriteLine ("Defs Version : Cannot find " & strDefsFile)
End If
Else
ObjOutputFile.WriteLine ("DisplayName : Unknown")
End If
ObjOutputFile.WriteLine ("--------------------------------------------------------")
End If
Loop
objOutputFile.Close
Set objOutputFile = fso.openTextFile("Results.txt", 1,True)
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "admin@domain.com"
objEmail.To = "subsun@domain.com"
objEmail.Subject = "AV Report"
objEmail.TextBody = objOutputfile.ReadAll
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTP Relay"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
ASKER
Sorry for the late response :
Thanks for your efforts, the script now prints the AV version correctly.. :-) But not the updated virus definition date. any suggestion?
Getting the following output
Server : SERVER
Display Name : Symantec Antivirus 10.1.6.6000
Defs File : Cannot find C:\PROGRA~1\COMMON~1\SYMAN T~1\VIRUSD ~1\2009052 2.002
Defs Version : Cannot find C:\PROGRA~1\COMMON~1\SYMAN T~1\VIRUSD ~1\2009052 2.002
-------------------------- ---------- ---------- ----------
Thanks for your efforts, the script now prints the AV version correctly.. :-) But not the updated virus definition date. any suggestion?
Getting the following output
Server : SERVER
Display Name : Symantec Antivirus 10.1.6.6000
Defs File : Cannot find C:\PROGRA~1\COMMON~1\SYMAN
Defs Version : Cannot find C:\PROGRA~1\COMMON~1\SYMAN
--------------------------
Hmm, can you verify whether the file
C:\PROGRA~1\COMMON~1\SYMAN T~1\VIRUSD ~1\2009052 2.002
actually exists on the machine? Does the 20090522.002 file maybe have another extension?
If the file is not there, what *is* in that VIRUSD~1 folder?
Regards,
Rob.
C:\PROGRA~1\COMMON~1\SYMAN
actually exists on the machine? Does the 20090522.002 file maybe have another extension?
If the file is not there, what *is* in that VIRUSD~1 folder?
Regards,
Rob.
ASKER
20090522.002 is a folder which contains several files. I have attached the file details.
dir.txt
dir.txt
OK, from that file list, I'm taken the "v.sig" file as *possibly* being the file that can give us the version. Check it out, and if it's not correct, can you do me a favour and check the properties of some likely files in that folder and see which one has the version info?
Regards,
Rob.
Regards,
Rob.
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Const HKEY_LOCAL_MACHINE = &H80000002
Set fso = CreateObject("Scripting.FileSystemObject")
Set objInputFile = fso.OpenTextFile("server.txt", 1, True)
Set ObjOutputFile = fso.OpenTextFile("Results.txt", 2, True)
Do While objInputFile.AtEndOfLine <> True
strComputer = objInputFile.Readline
On Error Resume Next
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\SecurityCenter")
' If the SecurityCenter namespace is available, query it
If Err.Number = 0 Then
Set colItems = objWMIService.ExecQuery("SELECT * FROM antivirusProduct", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
ObjOutputFile.WriteLine ("Server : " & strComputer)
ObjOutputFile.WriteLine ("DisplayName : " & objItem.DisplayName)
ObjOutputFile.WriteLine ("OnAccessScanningEnabled : " & objItem.OnAccessScanningEnabled)
ObjOutputFile.WriteLine ("productUptoDate : " & objItem.productUptoDate)
ObjOutputFile.WriteLine ("VersionNumber : " & objItem.VersionNumber)
ObjOutputFile.WriteLine ("--------------------------------------------------------")
Next
' Otherwise if the SecurityCenter namespance is not available, we can try the registry for a known product
Else
strSymantecEXE = "C:\Program Files\Symantec Antivirus\SymantecAV.exe"
strScanEngineEXE = "C:\Program Files\Common Files\Symantec Shared\ScanEngine.exe"
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Symantec\SharedDefs\"
strValueName = "NAVCORP_70"
ObjOutputFile.WriteLine ("Server : " & strComputer)
intReturn = objReg.GetStringValue(HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strDefsFolder)
If intReturn = 0 Then
ObjOutputFile.WriteLine ("DisplayName : Symantec Antivirus " & FSO.GetFileVersion(strSymantecEXE))
strDefsFile = strDefsFolder & "\v.sig"
If fso.FolderExists(strDefsFolder) = True Then
If fso.FileExists(strDefsFile) = True Then
ObjOutputFile.WriteLine ("Defs Folder : " & FSO.GetFolderName(strDefsFolder))
ObjOutputFile.WriteLine ("Defs File : " & FSO.GetFileName(strDefsFile))
ObjOutputFile.WriteLine ("Defs Version : " & FSO.GetFileVersion(strDefsFile))
Else
ObjOutputFile.WriteLine ("Defs Folder : " & FSO.GetFolderName(strDefsFolder))
ObjOutputFile.WriteLine ("Defs File : Cannot find " & strDefsFile)
ObjOutputFile.WriteLine ("Defs Version : Cannot find " & strDefsFile)
End If
Else
ObjOutputFile.WriteLine ("Defs Folder : Cannot find " & strDefsFolder)
ObjOutputFile.WriteLine ("Defs File : Cannot find " & strDefsFile)
ObjOutputFile.WriteLine ("Defs Version : Cannot find " & strDefsFile)
End If
Else
ObjOutputFile.WriteLine ("DisplayName : Unknown")
End If
ObjOutputFile.WriteLine ("--------------------------------------------------------")
End If
Loop
objOutputFile.Close
Set objOutputFile = fso.openTextFile("Results.txt", 1,True)
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "admin@domain.com"
objEmail.To = "subsun@domain.com"
objEmail.Subject = "AV Report"
objEmail.TextBody = objOutputfile.ReadAll
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTP Relay"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
ASKER
File ECMSVR32.DLL is giving the correct version of the AV. Also is it possible to add the last updated date? I think the modified date or V.SIG file or ECMSVR32.DLL file will give the updated date.
Thanks in advance.
Thanks in advance.
ASKER
Now the result comes like this.
Server : "Server"
DisplayName : Symantec Antivirus 10.1.6.6000
Defs File : ECMSVR32.DLL
Defs Version : 81.3.0.13
-------------------------- ---------- ---------- ----------
Instead of Defs File : ECMSVR32.DLL I would like to get Last updated : 22/05/2009
Server : "Server"
DisplayName : Symantec Antivirus 10.1.6.6000
Defs File : ECMSVR32.DLL
Defs Version : 81.3.0.13
--------------------------
Instead of Defs File : ECMSVR32.DLL I would like to get Last updated : 22/05/2009
ASKER
Sorry to say, but i end up with another issue :-(
The script gives the correct info if I run it from the same server. Any Idea?
Results:
Server : server1
DisplayName : Symantec Antivirus 10.1.6.6000
Defs File : ECMSVR32.DLL
Defs Version : 81.3.0.13
-------------------------- ---------- ---------- ----------
Server : server2
DisplayName : Symantec Antivirus 10.1.6.6000
Defs Folder : Cannot find C:\PROGRA~1\COMMON~1\SYMAN T~1\VIRUSD ~1\2009052 9.003
Defs File : Cannot find C:\PROGRA~1\COMMON~1\SYMAN T~1\VIRUSD ~1\2009052 9.003\ECMS VR32.DLL
Defs Version : Cannot find C:\PROGRA~1\COMMON~1\SYMAN T~1\VIRUSD ~1\2009052 9.003\ECMS VR32.DLL
-------------------------- ---------- ---------- ----------
The script gives the correct info if I run it from the same server. Any Idea?
Results:
Server : server1
DisplayName : Symantec Antivirus 10.1.6.6000
Defs File : ECMSVR32.DLL
Defs Version : 81.3.0.13
--------------------------
Server : server2
DisplayName : Symantec Antivirus 10.1.6.6000
Defs Folder : Cannot find C:\PROGRA~1\COMMON~1\SYMAN
Defs File : Cannot find C:\PROGRA~1\COMMON~1\SYMAN
Defs Version : Cannot find C:\PROGRA~1\COMMON~1\SYMAN
--------------------------
Oh yeah....try this....it now turns the file paths into UNC paths so that it reads the version on the remote server....
Regards,
Rob.
Regards,
Rob.
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Const HKEY_LOCAL_MACHINE = &H80000002
Set fso = CreateObject("Scripting.FileSystemObject")
Set objInputFile = fso.OpenTextFile("server.txt", 1, True)
Set ObjOutputFile = fso.OpenTextFile("Results.txt", 2, True)
Do While objInputFile.AtEndOfLine <> True
strComputer = objInputFile.Readline
On Error Resume Next
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\SecurityCenter")
' If the SecurityCenter namespace is available, query it
If Err.Number = 0 Then
Set colItems = objWMIService.ExecQuery("SELECT * FROM antivirusProduct", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
ObjOutputFile.WriteLine ("Server : " & strComputer)
ObjOutputFile.WriteLine ("DisplayName : " & objItem.DisplayName)
ObjOutputFile.WriteLine ("OnAccessScanningEnabled : " & objItem.OnAccessScanningEnabled)
ObjOutputFile.WriteLine ("productUptoDate : " & objItem.productUptoDate)
ObjOutputFile.WriteLine ("VersionNumber : " & objItem.VersionNumber)
ObjOutputFile.WriteLine ("--------------------------------------------------------")
Next
' Otherwise if the SecurityCenter namespance is not available, we can try the registry for a known product
Else
strSymantecEXE = "C:\Program Files\Symantec Antivirus\SymantecAV.exe"
strScanEngineEXE = "C:\Program Files\Common Files\Symantec Shared\ScanEngine.exe"
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Symantec\SharedDefs\"
strValueName = "NAVCORP_70"
ObjOutputFile.WriteLine ("Server : " & strComputer)
intReturn = objReg.GetStringValue(HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strDefsFolder)
If intReturn = 0 Then
strSymantecEXE = "\\" & strComputer & "\" & Replace(strSymantecEXE, ":", "$")
strScanEngineEXE = "\\" & strComputer & "\" & Replace(strScanEngineEXE, ":", "$")
ObjOutputFile.WriteLine ("DisplayName : Symantec Antivirus " & FSO.GetFileVersion(strSymantecEXE))
strDefsFile = strDefsFolder & "\ECMSVR32.DLL"
strDefsFile = "\\" & strComputer & "\" & Replace(strDefsFile, ":", "$")
If fso.FolderExists(strDefsFolder) = True Then
If fso.FileExists(strDefsFile) = True Then
ObjOutputFile.WriteLine ("Defs Folder : " & FSO.GetFolderName(strDefsFolder))
ObjOutputFile.WriteLine ("Last Updated : " & FSO.GetFile(strDefsFile).DateLastModified)
ObjOutputFile.WriteLine ("Defs Version : " & FSO.GetFileVersion(strDefsFile))
Else
ObjOutputFile.WriteLine ("Defs Folder : " & FSO.GetFolderName(strDefsFolder))
ObjOutputFile.WriteLine ("Last Updated : Cannot find " & strDefsFile)
ObjOutputFile.WriteLine ("Defs Version : Cannot find " & strDefsFile)
End If
Else
ObjOutputFile.WriteLine ("Defs Folder : Cannot find " & strDefsFolder)
ObjOutputFile.WriteLine ("Last Updated : Cannot find " & strDefsFile)
ObjOutputFile.WriteLine ("Defs Version : Cannot find " & strDefsFile)
End If
Else
ObjOutputFile.WriteLine ("DisplayName : Unknown")
End If
ObjOutputFile.WriteLine ("--------------------------------------------------------")
End If
Loop
objOutputFile.Close
Set objOutputFile = fso.openTextFile("Results.txt", 1,True)
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "admin@domain.com"
objEmail.To = "subsun@domain.com"
objEmail.Subject = "AV Report"
objEmail.TextBody = objOutputfile.ReadAll
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTP Relay"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
ASKER
Hi Rob, Sorry for the delay in response. It seems the script is not reading the remote server registry values. Could you please help?
Hmmm, as long as you can verify that this value exists on the registry on the remote machine:
HKLM\SOFTWARE\Symantec\Sha redDefs\NA VCORP_70
It should read the path. What does your Results.txt file have in it after you run the script?
Regards,
Rob.
HKLM\SOFTWARE\Symantec\Sha
It should read the path. What does your Results.txt file have in it after you run the script?
Regards,
Rob.
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Const HKEY_LOCAL_MACHINE = &H80000002
Set fso = CreateObject("Scripting.FileSystemObject")
Set objInputFile = fso.OpenTextFile("server.txt", 1, True)
Set ObjOutputFile = fso.OpenTextFile("Results.txt", 2, True)
Do While objInputFile.AtEndOfLine <> True
strComputer = objInputFile.Readline
On Error Resume Next
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\SecurityCenter")
' If the SecurityCenter namespace is available, query it
If Err.Number = 0 Then
Set colItems = objWMIService.ExecQuery("SELECT * FROM antivirusProduct", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each objItem In colItems
ObjOutputFile.WriteLine ("Server : " & strComputer)
ObjOutputFile.WriteLine ("DisplayName : " & objItem.DisplayName)
ObjOutputFile.WriteLine ("OnAccessScanningEnabled : " & objItem.OnAccessScanningEnabled)
ObjOutputFile.WriteLine ("productUptoDate : " & objItem.productUptoDate)
ObjOutputFile.WriteLine ("VersionNumber : " & objItem.VersionNumber)
ObjOutputFile.WriteLine ("--------------------------------------------------------")
Next
' Otherwise if the SecurityCenter namespance is not available, we can try the registry for a known product
Else
strSymantecEXE = "C:\Program Files\Symantec Antivirus\SymantecAV.exe"
strScanEngineEXE = "C:\Program Files\Common Files\Symantec Shared\ScanEngine.exe"
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Symantec\SharedDefs\"
strValueName = "NAVCORP_70"
ObjOutputFile.WriteLine ("Server : " & strComputer)
intReturn = objReg.GetStringValue(HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strDefsFolder)
If intReturn = 0 Then
strSymantecEXE = "\\" & strComputer & "\" & Replace(strSymantecEXE, ":", "$")
strScanEngineEXE = "\\" & strComputer & "\" & Replace(strScanEngineEXE, ":", "$")
ObjOutputFile.WriteLine ("DisplayName : Symantec Antivirus " & FSO.GetFileVersion(strSymantecEXE))
If Right(strDefsFolder, 1) = "\" Then strDefsFolder = Left(strDefsFolder, Len(strDefsFolder) - 1)
strDefsFile = strDefsFolder & "\ECMSVR32.DLL"
strDefsFile = "\\" & strComputer & "\" & Replace(strDefsFile, ":", "$")
If fso.FolderExists(strDefsFolder) = True Then
If fso.FileExists(strDefsFile) = True Then
ObjOutputFile.WriteLine ("Defs Folder : " & FSO.GetFolderName(strDefsFolder))
ObjOutputFile.WriteLine ("Last Updated : " & FSO.GetFile(strDefsFile).DateLastModified)
ObjOutputFile.WriteLine ("Defs Version : " & FSO.GetFileVersion(strDefsFile))
Else
ObjOutputFile.WriteLine ("Defs Folder : " & FSO.GetFolderName(strDefsFolder))
ObjOutputFile.WriteLine ("Last Updated : Cannot find " & strDefsFile)
ObjOutputFile.WriteLine ("Defs Version : Cannot find " & strDefsFile)
End If
Else
ObjOutputFile.WriteLine ("Defs Folder : Cannot find " & strDefsFolder)
ObjOutputFile.WriteLine ("Last Updated : Cannot find " & strDefsFile)
ObjOutputFile.WriteLine ("Defs Version : Cannot find " & strDefsFile)
End If
Else
ObjOutputFile.WriteLine ("DisplayName : Unknown")
End If
ObjOutputFile.WriteLine ("--------------------------------------------------------")
End If
Loop
objOutputFile.Close
MsgBox "Done"
Set objOutputFile = fso.openTextFile("Results.txt", 1,True)
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "admin@domain.com"
objEmail.To = "subsun@domain.com"
objEmail.Subject = "AV Report"
objEmail.TextBody = objOutputfile.ReadAll
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "SMTP Relay"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
ASKER
Following is the output which i am getting, I have verified the path for ECMSVR32.DLL is valid.
-------------------------- ---------- ---------- ----------
Server : server
DisplayName : Symantec Antivirus 10.1.6.6000
Last Updated : 11/20/2008 2:00:00 AM
Defs Version : 81.3.0.13
-------------------------- ---------- ---------- ----------
Server : Server1
DisplayName : Symantec Antivirus 10.1.6.6000
Defs Folder : Cannot find C:\PROGRA~1\COMMON~1\SYMAN T~1\VIRUSD ~1\2009060 2.007
Last Updated : Cannot find \\Server1\C$\PROGRA~1\COMM ON~1\SYMAN T~1\VIRUSD ~1\2009060 2.007\ECMS VR32.DLL
Defs Version : Cannot find \\Server1\C$\PROGRA~1\COMM ON~1\SYMAN T~1\VIRUSD ~1\2009060 2.007\ECMS VR32.DLL
-------------------------- ---------- ---------- ----------
Server : Server2
DisplayName : Symantec Antivirus 10.1.6.6000
Defs Folder : Cannot find C:\PROGRA~1\COMMON~1\SYMAN T~1\VIRUSD ~1\2009060 2.007
Last Updated : Cannot find \\Server2\C$\PROGRA~1\COMM ON~1\SYMAN T~1\VIRUSD ~1\2009060 2.007\ECMS VR32.DLL
Defs Version : Cannot find \\Server2\C$\PROGRA~1\COMM ON~1\SYMAN T~1\VIRUSD ~1\2009060 2.007\ECMS VR32.DLL
-------------------------- ---------- ---------- ----------
--------------------------
Server : server
DisplayName : Symantec Antivirus 10.1.6.6000
Last Updated : 11/20/2008 2:00:00 AM
Defs Version : 81.3.0.13
--------------------------
Server : Server1
DisplayName : Symantec Antivirus 10.1.6.6000
Defs Folder : Cannot find C:\PROGRA~1\COMMON~1\SYMAN
Last Updated : Cannot find \\Server1\C$\PROGRA~1\COMM
Defs Version : Cannot find \\Server1\C$\PROGRA~1\COMM
--------------------------
Server : Server2
DisplayName : Symantec Antivirus 10.1.6.6000
Defs Folder : Cannot find C:\PROGRA~1\COMMON~1\SYMAN
Last Updated : Cannot find \\Server2\C$\PROGRA~1\COMM
Defs Version : Cannot find \\Server2\C$\PROGRA~1\COMM
--------------------------
ASKER
Getting the following error when testing without "On Error Resume Next"
Microsoft VBScript runtime error: Object doesn't support this property or method: 'fso.GetFolderName'
Microsoft VBScript runtime error: Object doesn't support this property or method: 'fso.GetFolderName'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes...Success!!! I appreciate your patience... :-)
-------------------------- ---------- ---------- ---------- ---------- ---------- -------
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWA RE\INTEL\L ANDesk\Vir usProtect6 \CurrentVe rsion]
"Client Group"="Exch Cluster"
"Parent"="AVparentserver"
-------------------------- ---------- ---------- ---------- ---------- ---------- -------
In addition... Is it possible read and report the above registry string values? If there is no string available then the report should say...
Display Name : Symantec Antivirus 10.1.6.6000
Defs Folder : 20090604.002
Last Updated : 6/4/2009 1:11:52 PM
Defs Version : 81.3.0.13
Client Group: not available
Parent Server: not available
If all success then I would prefer to get an output like this
Server: Server1
Display Name : Symantec Antivirus 10.1.6.6000
Defs Folder : 20090604.002
Last Updated : 6/4/2009 1:11:52 PM
Defs Version : 81.3.0.13
ClientGroup : exchgroup
Parent Server: AVSAV
--------------------------
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWA
"Client Group"="Exch Cluster"
"Parent"="AVparentserver"
--------------------------
In addition... Is it possible read and report the above registry string values? If there is no string available then the report should say...
Display Name : Symantec Antivirus 10.1.6.6000
Defs Folder : 20090604.002
Last Updated : 6/4/2009 1:11:52 PM
Defs Version : 81.3.0.13
Client Group: not available
Parent Server: not available
If all success then I would prefer to get an output like this
Server: Server1
Display Name : Symantec Antivirus 10.1.6.6000
Defs Folder : 20090604.002
Last Updated : 6/4/2009 1:11:52 PM
Defs Version : 81.3.0.13
ClientGroup : exchgroup
Parent Server: AVSAV
ASKER
Appreciate your patience...
ASKER
Hi Rob,
I have added the code to pront the values and getting proper output now.. But, how to print "not available" if the string is not present or if value is blank? Please help. Also verify if i have done something wrong... :-)
I have added the code to pront the values and getting proper output now.. But, how to print "not available" if the string is not present or if value is blank? Please help. Also verify if i have done something wrong... :-)
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Const HKEY_LOCAL_MACHINE = &H80000002
Set fso = CreateObject("Scripting.FileSystemObject")
Set objInputFile = fso.OpenTextFile("server.txt", 1, True)
Set ObjOutputFile = fso.OpenTextFile("Results.txt", 2, True)
Do While objInputFile.AtEndOfLine <> True
strComputer = objInputFile.Readline
strSymantecEXE = "C:\Program Files\Symantec Antivirus\sav.exe"
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Symantec\SharedDefs\"
strValueName = "NAVCORP_70"
ObjOutputFile.WriteLine ("Server : " & strComputer)
intReturn = objReg.GetStringValue(HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strDefsFolder)
If intReturn = 0 Then
strSymantecEXE = "\\" & strComputer & "\" & Replace(strSymantecEXE, ":", "$")
ObjOutputFile.WriteLine ("AV Version : Symantec Antivirus " & FSO.GetFileVersion(strSymantecEXE))
If Right(strDefsFolder, 1) = "\" Then strDefsFolder = Left(strDefsFolder, Len(strDefsFolder) - 1)
strDefsFolder = "\\" & strComputer & "\" & Replace(strDefsFolder, ":", "$")
strDefsFile = strDefsFolder & "\ECMSVR32.DLL"
If fso.FolderExists(strDefsFolder) = True Then
If fso.FileExists(strDefsFile) = True Then
ObjOutputFile.WriteLine ("Defs Folder : " & FSO.GetFolder(strDefsFolder).Name)
ObjOutputFile.WriteLine ("Last Updated : " & FSO.GetFile(strDefsFile).Datecreated)
ObjOutputFile.WriteLine ("Defs Version : " & FSO.GetFileVersion(strDefsFile))
Else
ObjOutputFile.WriteLine ("Defs Folder : " & FSO.GetFolder(strDefsFolder).Name)
ObjOutputFile.WriteLine ("Last Updated : Cannot find " & strDefsFile)
ObjOutputFile.WriteLine ("Defs Version : Cannot find " & strDefsFile)
End If
Else
ObjOutputFile.WriteLine ("Defs Folder : Cannot find " & strDefsFolder)
ObjOutputFile.WriteLine ("Last Updated : Cannot find " & strDefsFile)
ObjOutputFile.WriteLine ("Defs Version : Cannot find " & strDefsFile)
End If
Else
ObjOutputFile.WriteLine ("DisplayName : Unknown")
End If
strKeyPath = "SOFTWARE\INTEL\LANDesk\VirusProtect6\CurrentVersion\"
strValueName = "ClientGroup"
strValueName1 = "Parent"
objReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue
objReg.GetStringValue HKEY_LOCAL_MACHINE,strKeyPath,strValueName1,strValue1
ObjOutputFile.WriteLine ("Client Group : " & strValue )
ObjOutputFile.WriteLine ("Parent Server : " & strValue1 )
ObjOutputFile.WriteLine ("--------------------------------------------------------")
Loop
objOutputFile.Close
Set objOutputFile = fso.openTextFile("Results.txt", 1,True)
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "avadmin@domain.com"
objEmail.To = "subsun@domain.com"
objEmail.Subject = "AV Report"
objEmail.TextBody = objOutputfile.ReadAll
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "test"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
MsgBox "Done"
Hi there. I'm glad we finally got there :-)
All you needed to do was catch the return code from the GetStringValue method, which I have done with intReturn and intReturn1.
If that code is zero, then the value was successfully retrieved. Otherwise, it doesn't exist.
Regards,
Rob.
All you needed to do was catch the return code from the GetStringValue method, which I have done with intReturn and intReturn1.
If that code is zero, then the value was successfully retrieved. Otherwise, it doesn't exist.
Regards,
Rob.
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Const HKEY_LOCAL_MACHINE = &H80000002
Set fso = CreateObject("Scripting.FileSystemObject")
Set objInputFile = fso.OpenTextFile("server.txt", 1, True)
Set ObjOutputFile = fso.OpenTextFile("Results.txt", 2, True)
Do While objInputFile.AtEndOfLine <> True
strComputer = objInputFile.Readline
strSymantecEXE = "C:\Program Files\Symantec Antivirus\sav.exe"
Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")
strKeyPath = "SOFTWARE\Symantec\SharedDefs\"
strValueName = "NAVCORP_70"
ObjOutputFile.WriteLine ("Server : " & strComputer)
intReturn = objReg.GetStringValue(HKEY_LOCAL_MACHINE, strKeyPath, strValueName, strDefsFolder)
If intReturn = 0 Then
strSymantecEXE = "\\" & strComputer & "\" & Replace(strSymantecEXE, ":", "$")
ObjOutputFile.WriteLine ("AV Version : Symantec Antivirus " & FSO.GetFileVersion(strSymantecEXE))
If Right(strDefsFolder, 1) = "\" Then strDefsFolder = Left(strDefsFolder, Len(strDefsFolder) - 1)
strDefsFolder = "\\" & strComputer & "\" & Replace(strDefsFolder, ":", "$")
strDefsFile = strDefsFolder & "\ECMSVR32.DLL"
If fso.FolderExists(strDefsFolder) = True Then
If fso.FileExists(strDefsFile) = True Then
ObjOutputFile.WriteLine ("Defs Folder : " & FSO.GetFolder(strDefsFolder).Name)
ObjOutputFile.WriteLine ("Last Updated : " & FSO.GetFile(strDefsFile).Datecreated)
ObjOutputFile.WriteLine ("Defs Version : " & FSO.GetFileVersion(strDefsFile))
Else
ObjOutputFile.WriteLine ("Defs Folder : " & FSO.GetFolder(strDefsFolder).Name)
ObjOutputFile.WriteLine ("Last Updated : Cannot find " & strDefsFile)
ObjOutputFile.WriteLine ("Defs Version : Cannot find " & strDefsFile)
End If
Else
ObjOutputFile.WriteLine ("Defs Folder : Cannot find " & strDefsFolder)
ObjOutputFile.WriteLine ("Last Updated : Cannot find " & strDefsFile)
ObjOutputFile.WriteLine ("Defs Version : Cannot find " & strDefsFile)
End If
Else
ObjOutputFile.WriteLine ("DisplayName : Unknown")
End If
strKeyPath = "SOFTWARE\INTEL\LANDesk\VirusProtect6\CurrentVersion\"
strValueName = "ClientGroup"
strValueName1 = "Parent"
intReturn = objReg.GetStringValue(HKEY_LOCAL_MACHINE,strKeyPath,strValueName,strValue)
intReturn1 = objReg.GetStringValue(HKEY_LOCAL_MACHINE,strKeyPath,strValueName1,strValue1)
If intReturn <> 0 Then
ObjOutputFile.WriteLine ("Client Group : Not available")
Else
ObjOutputFile.WriteLine ("Client Group : " & strValue)
End If
If intReturn1 <> 0 Then
ObjOutputFile.WriteLine ("Parent Server : Not available")
Else
ObjOutputFile.WriteLine ("Parent Server : " & strValue1)
End If
ObjOutputFile.WriteLine ("--------------------------------------------------------")
Loop
objOutputFile.Close
Set objOutputFile = fso.openTextFile("Results.txt", 1,True)
Set objEmail = CreateObject("CDO.Message")
objEmail.From = "avadmin@domain.com"
objEmail.To = "subsun@domain.com"
objEmail.Subject = "AV Report"
objEmail.TextBody = objOutputfile.ReadAll
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "test"
objEmail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
MsgBox "Done"