Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

VB script to find Sophos EndPoint installed on network computer

Posted on 2014-10-23
7
Medium Priority
?
225 Views
Last Modified: 2016-02-25
Hi All, I need help to amend a VB script, the script will check two things, computers on the network for an application  if its installed, i.e. Sophos EndPoint, and which version its running.
Once checked if its running Sophos and which version it will send the results through email.
I have attached the script so far what i have worked on.... it does work and reports if any computers doesn't have sophos, but iam not able to find out the version installed through script....need help in that....
i have attached the script......
Script.txt
0
Comment
Question by:Leo
7 Comments
 
LVL 12

Expert Comment

by:jkaios
ID: 40401032
Try the GetFileVersion method of the File System Object:

objMessage.TextBody = objNetwork.Username & " " & strIP & " File Version: " & objFSO.GetFileVersion(strFile)

Open in new window

0
 
LVL 8

Author Comment

by:Leo
ID: 40401064
Where i should insert it?
and in the GetFileVersion, where do i have to specify it should be only checking the file version for Sophos?
0
 
LVL 84

Accepted Solution

by:
David Johnson, CD, MVP earned 2000 total points
ID: 40401198
notice the changes to the code as

Option Explicit
'=======================================================
'File:	NoSophos.vbs
'Version:	1.0
'Description
'Checks for the existence of a Sophos file and email if it doesn't exist.
'=======================================================
Const x86_SAV = "C:\Program Files\Sophos\Sophos Anti-Virus\SavProxy.exe"
Const x64_SAV = "C:\Program Files (x86)\Sophos\Sophos Anti-Virus\SavProxy.exe"
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Dim wshShell : Set wshShell = Wscript.CreateObject("Wscript.Shell")
Dim objFSO : set objFSO = createobject("Scripting.FileSystemObject")
Dim objMessage : Set objMessage = CreateObject("CDO.Message") 
Dim WshNetwork : Set WshNetwork = CreateObject("WScript.Network")
Dim strComputer
Dim objNetwork : Set objNetwork = wscript.CreateObject("wscript.network")
Dim strIP
Dim strcomputerIP
Dim objWMIService
Dim colItems
Dim strCount
Dim objitem
Dim strIPAddress
Dim Architecture
Dim strFile
strComputer = WshNetwork.ComputerName 
Architecture =  WshShell.RegRead("HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PROCESSOR_ARCHITECTURE")

If InStr(Architecture,"86") <> 0 Then 
	strFile = x86_SAV
ElseIf InStr(Architecture,"64") <> 0 Then 
	strFile = x64_SAV
Else
	' unknown result, fail gracefully
	WScript.Quit
End If
strcomputerIP = "."
	Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputerIP & "\root\cimv2")
		Set colItems = objWMIService.ExecQuery("Select * From Win32_NetworkAdapterConfiguration Where IPEnabled = True")
	    	strCount = 1
		For Each objitem in colitems
	    If strCount = 1 Then
	        strIPAddress = Join(objitem.IPAddress, ",")
	        strIP = stripaddress
	        strCount = strCount + 1
	      Else
	    End If
		next
If (NOT objFSO.FileExists(strFile)) Then
	objMessage.Subject = "Sophos not installed" 
objMessage.TextBody = objNetwork.Username & " " & strIP & objMessage.Subject
else
objMessage.Subject = "Sophos Installed"
	    objMessage.TextBody = objNetwork.Username & " " & strIP & " File Version: " & objFSO.GetFileVersion(strFile)
End if
	objMessage.From = strComputer & "@EmailServer" 
	objMessage.To = "test1@EmailServer" 
	objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
	objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.EmailServer"
	objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
	objMessage.Configuration.Fields.Update
	objMessage.Send

Open in new window

0
NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

 
LVL 8

Author Comment

by:Leo
ID: 40405759
thanks, its working :-)
can you please tell me briefly how the script is working? then i will close off the ticket.
0
 
LVL 84

Expert Comment

by:David Johnson, CD, MVP
ID: 40405799
all I did was combine all of the items that are common and only separate out the ones that are different i.e. processor architecture.
0
 
LVL 8

Author Comment

by:Leo
ID: 40405820
ok, but how does it retrieve information for Sophos installed on computers?
0
 
LVL 14

Expert Comment

by:brendanmeyer
ID: 40405843
here is a script for getting the version

doesnt gather ip network information though

checks "Programs and Features" Installed list

Option Explicit

Const HKLM = &H80000002 'HKEY_LOCAL_MACHINE 
	
Dim objMessage : Set objMessage = CreateObject("CDO.Message") 	
Dim objNetwork : Set objNetwork = CreateObject("WScript.Network")
Dim strComputer
Dim Architecture
Dim objReg
Dim strKey
Dim arrSubkeys
Dim strSubkey
Dim intRet1
Dim strDisplayName 
Dim intVersionMajor
Dim intVersionMinor
Dim strProgramDisplayName
Dim intProgramVersionMajor
Dim intProgramVersionMinor


strComputer = objNetwork.ComputerName 

Set objReg = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\default:StdRegProv")

strKey = "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\" 

objReg.EnumKey HKLM, strKey, arrSubkeys 

'WScript.Echo "Installed Applications" & VbCrLf 
For Each strSubkey In arrSubkeys 
	intRet1 = objReg.GetStringValue(HKLM, strKey & strSubkey, "DisplayName", strDisplayName) 
	If intRet1 <> 0 Then 
		objReg.GetStringValue HKLM, strKey & strSubkey, "QuietDisplayName", strDisplayName 
	End If 
	objReg.GetDWORDValue HKLM, strKey & strSubkey, "VersionMajor", intVersionMajor
	objReg.GetDWORDValue HKLM, strKey & strSubkey, "VersionMinor", intVersionMinor

	On Error Resume  Next
	'WScript.Echo strDisplayName
	On Error Goto 0
	If InStr(1, strDisplayName, "sophos", 1) Then 
		strProgramDisplayName = strDisplayName
		intProgramVersionMajor = intVersionMajor
		intProgramVersionMinor = intVersionMinor
	End If
Next 

If strProgramDisplayName <> "" Then
	WScript.Echo VbCrLf & "Display Name: " & strProgramDisplayName
	WScript.Echo "Version: " & intProgramVersionMajor & "." & intProgramVersionMinor
			
	objMessage.Subject = "Sophos installed" 
	objMessage.TextBody = objNetwork.Username & " " & strComputer & VbCrLf & "Display Name: " & strProgramDisplayName & VbCrLf & "Version: " & intProgramVersionMajor & "." & intProgramVersionMinor
Else
	objMessage.Subject = "Sophos not installed" 
	objMessage.TextBody = objNetwork.Username & " " & strComputer
End If

objMessage.From = strComputer & "@EmailServer" 
objMessage.To = "test1@EmailServer" 

objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.EmailServer"
objMessage.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objMessage.Configuration.Fields.Update

objMessage.Send

Open in new window

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn different types of Android Layout and some basics of an Android App.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

783 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question