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
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

Open in new window

LVL 40
SubsunAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
Do you have any blank lines in your text files?
0
RobSampsonCommented:
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.
0
SubsunAuthor Commented:
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.
0
Exploring SharePoint 2016

Explore SharePoint 2016, the web-based, collaborative platform that integrates with Microsoft Office to provide intranets, secure document management, and collaboration so you can develop your online and offline capabilities.

RobSampsonCommented:
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\Common Client
HKLM\SOFTWARE\Symantec\SharedDefs

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.
0
SubsunAuthor Commented:
How to convert this registry values to readable string? Any idea?
0
RobSampsonCommented:
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.
0
SubsunAuthor Commented:
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
0
RobSampsonCommented:
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.
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

Open in new window

0
SubsunAuthor Commented:
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\SYMANT~1\VIRUSD~1\20090522.002
Defs Version : Cannot find C:\PROGRA~1\COMMON~1\SYMANT~1\VIRUSD~1\20090522.002
--------------------------------------------------------
0
RobSampsonCommented:
Hmm, can you verify whether the file
C:\PROGRA~1\COMMON~1\SYMANT~1\VIRUSD~1\20090522.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.
0
SubsunAuthor Commented:
20090522.002 is a folder which contains several files. I have attached the file details.
dir.txt
0
RobSampsonCommented:
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.
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

Open in new window

0
SubsunAuthor Commented:
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.
0
SubsunAuthor Commented:
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
0
SubsunAuthor Commented:
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\SYMANT~1\VIRUSD~1\20090529.003
Defs File      : Cannot find C:\PROGRA~1\COMMON~1\SYMANT~1\VIRUSD~1\20090529.003\ECMSVR32.DLL
Defs Version : Cannot find C:\PROGRA~1\COMMON~1\SYMANT~1\VIRUSD~1\20090529.003\ECMSVR32.DLL
--------------------------------------------------------
0
RobSampsonCommented:
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.
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

Open in new window

0
SubsunAuthor Commented:
Hi Rob, Sorry for the delay in response. It seems the script is not reading the remote server registry values. Could you please help?
0
RobSampsonCommented:
Hmmm, as long as you can verify that this value exists on the registry on the remote machine:
HKLM\SOFTWARE\Symantec\SharedDefs\NAVCORP_70

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

Open in new window

0
SubsunAuthor Commented:
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\SYMANT~1\VIRUSD~1\20090602.007
Last Updated  : Cannot find \\Server1\C$\PROGRA~1\COMMON~1\SYMANT~1\VIRUSD~1\20090602.007\ECMSVR32.DLL
Defs Version : Cannot find \\Server1\C$\PROGRA~1\COMMON~1\SYMANT~1\VIRUSD~1\20090602.007\ECMSVR32.DLL
--------------------------------------------------------
Server      : Server2
DisplayName      : Symantec Antivirus 10.1.6.6000
Defs Folder      : Cannot find C:\PROGRA~1\COMMON~1\SYMANT~1\VIRUSD~1\20090602.007
Last Updated  : Cannot find \\Server2\C$\PROGRA~1\COMMON~1\SYMANT~1\VIRUSD~1\20090602.007\ECMSVR32.DLL
Defs Version : Cannot find \\Server2\C$\PROGRA~1\COMMON~1\SYMANT~1\VIRUSD~1\20090602.007\ECMSVR32.DLL
--------------------------------------------------------
0
SubsunAuthor Commented:
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'
0
RobSampsonCommented:
Oh! From your output I can see that Defs Folder is still a local drive reference! I change the File to UNC, but not the folder! My bad! Try this.

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)
			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).DateLastModified)
					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
		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

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SubsunAuthor Commented:
Yes...Success!!!  I appreciate your patience... :-)
-----------------------------------------------------------------------------------
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\INTEL\LANDesk\VirusProtect6\CurrentVersion]
"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
0
SubsunAuthor Commented:
Appreciate your patience...
0
SubsunAuthor Commented:
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... :-)
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"

Open in new window

0
RobSampsonCommented:
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.
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"

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.