Find all network computers that do not have Sophos Installed

Hi,
I am looking for a logon script that will check if the computer does not have Sophos installed by checking the "C:\Program Files\Sophos\.." and logging the results to a text file on a network share with the following information:
Computer name
IP Address
Username
ZknAsked:
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.

RunningGagCommented:
The easiest method would be to check the uninstall key in the registry.  Just search this folder:

HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\

For the key and its a simple,

If strKey then create text file.

Reading the key is:

' Specify the key and the path
strKey = "YourKeyHere"
strRegPath = "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Uninstall\" & strKey

Set objShell = CreateObject("WScript.Shell")

' Read the specified key
strRegKey = objShell.RegRead(strRegPath)
0
ZknAuthor Commented:
Appreicate your response. I am actually looking for a script that will log the computer name, IP address and username as well to a network path specified in the logon script of the computers that do not have Sophos installed.
0
jhalapradeepCommented:
Hi,

Please download the attached batch file:

1) the folder name is : Folder Checker
2) Copy this folder to the C:\ of the main server
3) There are 3 files in it. Please rename app1.txt to app1.bat and also app2.txt to app2.bat
4) You need to enter the list of computer names in single column in ip.txt file
5) you need to run the app1.bat file so that it will take computer names from the ip.txt file and then start the app2.bat file for operation
6) Please edit the batch file to enter the desired folder path.
7) This attached script is to find if there is SCCM client installed or not.
8) MOST IMP: you need to run this batch file as local administrator on the server. This account should be a local admin to all the clients on the network.  Other wise it will not created desired results/

9) Once executed it will create a file result.txt  which will show you if the machine was pingable or not and whether the desired folder existed on that computer name.

Please let me know if any more queries.

Regards,
Pradeep Jhala

Folder-Checker.zip
0
Introducing the "443 Security Simplified" Podcast

This new podcast puts you inside the minds of leading white-hat hackers and security researchers. Hosts Marc Laliberte and Corey Nachreiner turn complex security concepts into easily understood and actionable insights on the latest cyber security headlines and trends.

ZknAuthor Commented:
Is it possible that I can have a vbs script that I can run as a logon script. The logon script should capture the computer name, IP Address and username to a text file. We would like to run it as a logon script so that we can know the status of every computer that logs on if it has the Sophos client installed or not.

Thank you
0
ZknAuthor Commented:
Can someone please help me with my request?
0
merowingerCommented:
check the below listed script
set objFSO = CreateObject("Scripting.FileSystemObject")
set objNet = CreateObject("Wscript.Network")
strLogFile = "\\Server\share\Output.log"

If Not objFSO.FileExists(strLogFile) Then
	set objFile = objFSO.CreateTextFile(strLogFile)
Else
	set objFile = objFSO.OpenTextFile(strLogFile,8)
End If


objFile.Writeline Now &" - " & objNet.Username
objFile.Writeline Now &" - " & objNet.Computername

If objFSo.FolderExists("C:\Program Files\Sophos") Then
	objFile.Writeline Now &" - Sophos installed"
Else
	objFile.Writeline Now &" - Sophos not installed"
End If



Set IPConfigSet = GetObject("winmgmts://.").ExecQuery("select * from Win32_NetworkAdapterConfiguration where IPEnabled=TRUE")
For Each IPConfig In IPConfigSet
	If Not IsNull(IPConfig.IPAddress) Then
		For i=LBound(IPConfig.IPAddress) To UBound(IPConfig.IPAddress)
			objFile.Writeline Now &" - IPAddress: " & IPConfig.IPAddress(i)  
		Next
	End If
Next

Open in new window

0
ZknAuthor Commented:
Thank you for the script, couple of things:
1) It is not generating the IP address in the Log file
2) May I also have the output on one line, for e.g. Username, ComputerName and IP address

This is exactly what I was looking for, if you can fix the above we will be in good shape
0
ZknAuthor Commented:
Quick note, we run the following logon script to track each user when they logon to the network, is it possible that you can modify this script so that it can check if sohpos is installed or not too. Below is the script:
' Start of Script

Option Explicit

' Declare Variables
Dim objFSO, objLogFile, objNetwork, objShell, strText, intAns
Dim intConstants, intTimeout, strTitle, intCount, blnLog
Dim strUserName, strComputerName, strIP, strShare, strLogFile

' Define Variables
strShare = "\\iesipmonitor\UserLogFiles"
strLogFile = "IOfficeLogon.txt"
intTimeout = 20

' Instantiate objects
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("Wscript.Network")
Set objShell = CreateObject("Wscript.Shell")

' Define variables
strUserName = objNetwork.UserName
strComputerName = objNetwork.ComputerName
strIP = Join(GetIPAddresses())

' Log date/time, user name, computer name, and IP address.
If (objFSO.FolderExists(strShare) = True) Then
    On Error Resume Next
    Set objLogFile = objFSO.OpenTextFile(strShare & "\" _
        & strLogFile, 8, True, 0)
    If (Err.Number = 0) Then
' Make three attempts to write to log file.
        intCount = 1
        blnLog = False
        Do Until intCount = 3
            objLogFile.WriteLine "Logon ; "  & Now & " ; " _
                & strComputerName & " ; " & strUserName & " ; " & strIP
            If (Err.Number = 0) Then
                intCount = 3
                blnLog = True
            Else
                Err.Clear
                intCount = intCount + 1
                If (Wscript.Version > 5) Then
                    Wscript.Sleep 200
                End If
            End If
        Loop
        'On Error GoTo 0
        If (blnLog = False) Then
            strTitle = "Logon Error"
            strText = "Log cannot be written."
            strText = strText & vbCrlf _
                & "Another process may have log file open."
            intConstants = vbOKOnly + vbExclamation
            intAns = objShell.Popup(strText, intTimeout, strTitle, _
                intConstants)
        End If
        objLogFile.Close
    Else
        'On Error GoTo 0
        strTitle = "Logon Error"
        strText = "Log cannot be written."
        strText = strText & vbCrLf & "User may not have permissions,"
        strText = strText & vbCrLf & "or log folder may not be shared."
        intConstants = vbOKOnly + vbExclamation
        intAns = objShell.Popup(strText, intTimeout, strTitle, intConstants)
    End If
    Set objLogFile = Nothing
End If

Function GetIPAddresses()
' Based on a Michael Harris script, modified by Torgeir Bakken
' Returns array of IP Addresses as output by IPConfig
' Win98/WinNT have IPConfig (Win95 doesn't)
' Win98/Win95 have WinIPCfg (WinNt doesn't)
' Note: The PPP Adapter (Dial Up Adapter) is excluded if not connected (IP address will be 0.0.0.0)
' and included if it is connected.

    Dim objShell, objFSO, objEnv, strWorkFile, objFile
    Dim arrData, intIndex, n, arrIPAddresses, arrParts

    Set objShell = CreateObject("wscript.shell")
    Set objFSO = CreateObject("scripting.filesystemobject")
    Set objEnv = objShell.Environment("PROCESS")
    If (objEnv("OS") = "Windows_NT") Then
        strWorkFile = objEnv("TEMP") & "\" & objFSO.GetTempName
        objShell.Run "%comspec% /c IPConfig >" & Chr(34) _
            & strWorkFile & Chr(34), 0, True
    Else
' WinIPCfg in batch mode sends output to filename WinIPCfg.out
    End If
    Set objShell = Nothing
    Set objFile = objFSO.OpenTextFile(strWorkFile)
    arrData = Split(objFile. ReadAll, vbCrLf)
    objFile.Close
    Set objFile = Nothing
    objFSO.DeleteFile strWorkFile
    Set objFSO = Nothing
    arrIPAddresses = Array()
    intIndex = -1
    For n = 0 To UBound(arrData)
        If (InStr(arrData(n), "IP Address") > 0) Then
            arrParts = Split(arrData(n), ":")
            If (InStr(Trim(arrParts(1)), "0.0.0.0") = 0) Then
                intIndex = intIndex + 1
                ReDim Preserve arrIPAddresses(intIndex)
                arrIPAddresses(intIndex)= Trim(CStr(arrParts(1)))
            End If
        End If
    Next
    GetIPAddresses = arrIPAddresses
End Function

' End of Script
'**************************************************************************************************
0
ZknAuthor Commented:
Can someone please help with this!!!! Thank you so much....
0
merowingerCommented:
see below
Option Explicit

' Declare Variables
Dim objFSO, objLogFile, objNetwork, objShell, strText, intAns
Dim intConstants, intTimeout, strTitle, intCount, blnLog
Dim strUserName, strComputerName, strIP, strShare, strLogFile

' Define Variables
strShare = "\\iesipmonitor\UserLogFiles"
strLogFile = "IOfficeLogon.txt"
intTimeout = 20

' Instantiate objects
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objNetwork = CreateObject("Wscript.Network")
Set objShell = CreateObject("Wscript.Shell")

' Define variables
strUserName = objNetwork.UserName
strComputerName = objNetwork.ComputerName
strIP = Join(GetIPAddresses())

' Log date/time, user name, computer name, and IP address.
If (objFSO.FolderExists(strShare) = True) Then
    On Error Resume Next
    Set objLogFile = objFSO.OpenTextFile(strShare & "\" _
        & strLogFile, 8, True, 0)
    If (Err.Number = 0) Then
' Make three attempts to write to log file.
        intCount = 1
        blnLog = False
        Do Until intCount = 3
            objLogFile.WriteLine "Logon ; "  & Now & " ; " _
                & strComputerName & " ; " & strUserName & " ; " & strIP
            If (Err.Number = 0) Then
                intCount = 3
                blnLog = True
            Else
                Err.Clear
                intCount = intCount + 1
                If (Wscript.Version > 5) Then
                    Wscript.Sleep 200
                End If
            End If
        Loop
        
' Check if Sophos is installed        
        If objFSo.FolderExists("C:\Program Files\Sophos") Then 
        	objLogFile.Writeline Now &" - Sophos installed" 
		Else 
        	objLogFile.Writeline Now &" - Sophos not installed" 
		End If 
        
        'On Error GoTo 0
        If (blnLog = False) Then
            strTitle = "Logon Error"
            strText = "Log cannot be written."
            strText = strText & vbCrlf _
                & "Another process may have log file open."
            intConstants = vbOKOnly + vbExclamation
            intAns = objShell.Popup(strText, intTimeout, strTitle, _
                intConstants)
        End If
        objLogFile.Close
    Else
        'On Error GoTo 0
        strTitle = "Logon Error"
        strText = "Log cannot be written."
        strText = strText & vbCrLf & "User may not have permissions,"
        strText = strText & vbCrLf & "or log folder may not be shared."
        intConstants = vbOKOnly + vbExclamation
        intAns = objShell.Popup(strText, intTimeout, strTitle, intConstants)
    End If
    Set objLogFile = Nothing
End If

Function GetIPAddresses()
' Based on a Michael Harris script, modified by Torgeir Bakken
' Returns array of IP Addresses as output by IPConfig
' Win98/WinNT have IPConfig (Win95 doesn't)
' Win98/Win95 have WinIPCfg (WinNt doesn't)
' Note: The PPP Adapter (Dial Up Adapter) is excluded if not connected (IP address will be 0.0.0.0)
' and included if it is connected.

    Dim objShell, objFSO, objEnv, strWorkFile, objFile
    Dim arrData, intIndex, n, arrIPAddresses, arrParts

    Set objShell = CreateObject("wscript.shell")
    Set objFSO = CreateObject("scripting.filesystemobject")
    Set objEnv = objShell.Environment("PROCESS")
    If (objEnv("OS") = "Windows_NT") Then
        strWorkFile = objEnv("TEMP") & "\" & objFSO.GetTempName
        objShell.Run "%comspec% /c IPConfig >" & Chr(34) _
            & strWorkFile & Chr(34), 0, True
    Else
' WinIPCfg in batch mode sends output to filename WinIPCfg.out
    End If
    Set objShell = Nothing
    Set objFile = objFSO.OpenTextFile(strWorkFile)
    arrData = Split(objFile. ReadAll, vbCrLf)
    objFile.Close
    Set objFile = Nothing
    objFSO.DeleteFile strWorkFile
    Set objFSO = Nothing
    arrIPAddresses = Array()
    intIndex = -1
    For n = 0 To UBound(arrData)
        If (InStr(arrData(n), "IP Address") > 0) Then
            arrParts = Split(arrData(n), ":")
            If (InStr(Trim(arrParts(1)), "0.0.0.0") = 0) Then
                intIndex = intIndex + 1
                ReDim Preserve arrIPAddresses(intIndex)
                arrIPAddresses(intIndex)= Trim(CStr(arrParts(1)))
            End If
        End If
    Next
    GetIPAddresses = arrIPAddresses
End Function

Open in new window

0
ZknAuthor Commented:
Awesome, thank you for your help. Minor change can the output sophos is installed be on the same line for e.g. Date, Computername, Username, IP address, Sophos is installed
It is generating the output in a new line which will be difficult to manipulate if you have too many users.

Thank you
0
merowingerCommented:
like this?
Option Explicit 
 
' Declare Variables 
Dim objFSO, objLogFile, objNetwork, objShell, strText, intAns 
Dim intConstants, intTimeout, strTitle, intCount, blnLog 
Dim strUserName, strComputerName, strIP, strShare, strLogFile 
 
' Define Variables 
strShare = "\\iesipmonitor\UserLogFiles" 
strLogFile = "IOfficeLogon.txt" 
intTimeout = 20 
 
' Instantiate objects 
Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objNetwork = CreateObject("Wscript.Network") 
Set objShell = CreateObject("Wscript.Shell") 
 
' Define variables 
strUserName = objNetwork.UserName 
strComputerName = objNetwork.ComputerName 
strIP = Join(GetIPAddresses()) 
 
' Log date/time, user name, computer name, and IP address. 
If (objFSO.FolderExists(strShare) = True) Then 
    On Error Resume Next 
    Set objLogFile = objFSO.OpenTextFile(strShare & "\" _ 
        & strLogFile, 8, True, 0) 
    If (Err.Number = 0) Then 

' Check if Sophos is installed         
		If objFSo.FolderExists("C:\Program Files\Sophos") Then  
			strSophos = "Sophos is installed"  
		Else  
			strSophos = "Sophos is not installed"  
		End If  
         


' Make three attempts to write to log file. 
        intCount = 1 
        blnLog = False 
        Do Until intCount = 3 
            objLogFile.WriteLine "Logon ; "  & Now & " ; " _ 
                & strComputerName & " ; " & strUserName & " ; " & strIP & " ; " &strSophos
            If (Err.Number = 0) Then 
                intCount = 3 
                blnLog = True 
            Else 
                Err.Clear 
                intCount = intCount + 1 
                If (Wscript.Version > 5) Then 
                    Wscript.Sleep 200 
                End If 
            End If 
        Loop 
         

        'On Error GoTo 0 
        If (blnLog = False) Then 
            strTitle = "Logon Error" 
            strText = "Log cannot be written." 
            strText = strText & vbCrlf _ 
                & "Another process may have log file open." 
            intConstants = vbOKOnly + vbExclamation 
            intAns = objShell.Popup(strText, intTimeout, strTitle, _ 
                intConstants) 
        End If 
        objLogFile.Close 
    Else 
        'On Error GoTo 0 
        strTitle = "Logon Error" 
        strText = "Log cannot be written." 
        strText = strText & vbCrLf & "User may not have permissions," 
        strText = strText & vbCrLf & "or log folder may not be shared." 
        intConstants = vbOKOnly + vbExclamation 
        intAns = objShell.Popup(strText, intTimeout, strTitle, intConstants) 
    End If 
    Set objLogFile = Nothing 
End If 
 
Function GetIPAddresses() 
' Based on a Michael Harris script, modified by Torgeir Bakken 
' Returns array of IP Addresses as output by IPConfig 
' Win98/WinNT have IPConfig (Win95 doesn't) 
' Win98/Win95 have WinIPCfg (WinNt doesn't) 
' Note: The PPP Adapter (Dial Up Adapter) is excluded if not connected (IP address will be 0.0.0.0) 
' and included if it is connected. 
 
    Dim objShell, objFSO, objEnv, strWorkFile, objFile 
    Dim arrData, intIndex, n, arrIPAddresses, arrParts 
 
    Set objShell = CreateObject("wscript.shell") 
    Set objFSO = CreateObject("scripting.filesystemobject") 
    Set objEnv = objShell.Environment("PROCESS") 
    If (objEnv("OS") = "Windows_NT") Then 
        strWorkFile = objEnv("TEMP") & "\" & objFSO.GetTempName 
        objShell.Run "%comspec% /c IPConfig >" & Chr(34) _ 
            & strWorkFile & Chr(34), 0, True 
    Else 
' WinIPCfg in batch mode sends output to filename WinIPCfg.out 
    End If 
    Set objShell = Nothing 
    Set objFile = objFSO.OpenTextFile(strWorkFile) 
    arrData = Split(objFile. ReadAll, vbCrLf) 
    objFile.Close 
    Set objFile = Nothing 
    objFSO.DeleteFile strWorkFile 
    Set objFSO = Nothing 
    arrIPAddresses = Array() 
    intIndex = -1 
    For n = 0 To UBound(arrData) 
        If (InStr(arrData(n), "IP Address") > 0) Then 
            arrParts = Split(arrData(n), ":") 
            If (InStr(Trim(arrParts(1)), "0.0.0.0") = 0) Then 
                intIndex = intIndex + 1 
                ReDim Preserve arrIPAddresses(intIndex) 
                arrIPAddresses(intIndex)= Trim(CStr(arrParts(1))) 
            End If 
        End If 
    Next 
    GetIPAddresses = arrIPAddresses 
End Function

Open in new window

0
ZknAuthor Commented:
I tried running the script but it is generating this error:
Log cannot be written
Another process may have log file open

0
merowingerCommented:
on which line? I've just changed the postion. I think there's another problem.Do you have closed the logfile?
0
ZknAuthor Commented:
it does not show the line number, but the error pops up in windows when you try to run the script. Yes, the logfile is closed, I even tried renaming the logfile as a test, but the same error shows up.
 

4-9-2010-4-47-21-PM.png
0
merowingerCommented:
first try to uncomment the "On Error Resume Next" lines to see which errors occures

Seems that there is a püroblem with this line:
Set objLogFile = objFSO.OpenTextFile(strShare & "\" & strLogFile, 8, True, 0)

Could you try this one instead
Set objLogFile = objFSO.OpenTextFile(strShare & "\" & strLogFile, 8)
0
RunningGagCommented:
Heh, you forgot to define strSophos.

Add to the top of the script, the line:

Dim strSophos


Also, good coding practice would be to add the line:

On Error Goto 0

After you open the log file.  Otherwise you're ignoring all errors for the rest of the script.
Option Explicit 
 
' Declare Variables 
Dim objFSO, objLogFile, objNetwork, objShell, strText, intAns 
Dim intConstants, intTimeout, strTitle, intCount, blnLog 
Dim strUserName, strComputerName, strIP, strShare, strLogFile, strSophos
 
' Define Variables 
strShare = "C:\" 
strLogFile = "IOfficeLogon.txt" 
intTimeout = 20 
 
' Instantiate objects 
Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objNetwork = CreateObject("Wscript.Network") 
Set objShell = CreateObject("Wscript.Shell") 
 
' Define variables 
strUserName = objNetwork.UserName 
strComputerName = objNetwork.ComputerName 
strIP = Join(GetIPAddresses()) 
 
' Log date/time, user name, computer name, and IP address. 
If (objFSO.FolderExists(strShare) = True) Then 
    On Error Resume Next 
    Set objLogFile = objFSO.OpenTextFile(strShare & "\" _ 
        & strLogFile, 8, True, 0) 
	On Error Goto 0
    If (Err.Number = 0) Then 

' Check if Sophos is installed         
		If objFSo.FolderExists("C:\Program Files\Sophos") Then  
			strSophos = "Sophos is installed"  
		Else  
			strSophos = "Sophos is not installed"  
		End If  
         


' Make three attempts to write to log file. 
        intCount = 1 
        blnLog = False 
        Do Until intCount = 3 
            objLogFile.WriteLine "Logon ; "  & Now & " ; " _ 
                & strComputerName & " ; " & strUserName & " ; " & strIP & " ; " &strSophos
            If (Err.Number = 0) Then 
                intCount = 3 
                blnLog = True 
            Else 
                Err.Clear 
                intCount = intCount + 1 
                If (Wscript.Version > 5) Then 
                    Wscript.Sleep 200 
                End If 
            End If 
        Loop 
         

        'On Error GoTo 0 
        If (blnLog = False) Then 
            strTitle = "Logon Error" 
            strText = "Log cannot be written." 
            strText = strText & vbCrlf _ 
                & "Another process may have log file open." 
            intConstants = vbOKOnly + vbExclamation 
            intAns = objShell.Popup(strText, intTimeout, strTitle, _ 
                intConstants) 
        End If 
        objLogFile.Close 
    Else 
        'On Error GoTo 0 
        strTitle = "Logon Error" 
        strText = "Log cannot be written." 
        strText = strText & vbCrLf & "User may not have permissions," 
        strText = strText & vbCrLf & "or log folder may not be shared." 
        intConstants = vbOKOnly + vbExclamation 
        intAns = objShell.Popup(strText, intTimeout, strTitle, intConstants) 
    End If 
    Set objLogFile = Nothing 
End If 
 
Function GetIPAddresses() 
' Based on a Michael Harris script, modified by Torgeir Bakken 
' Returns array of IP Addresses as output by IPConfig 
' Win98/WinNT have IPConfig (Win95 doesn't) 
' Win98/Win95 have WinIPCfg (WinNt doesn't) 
' Note: The PPP Adapter (Dial Up Adapter) is excluded if not connected (IP address will be 0.0.0.0) 
' and included if it is connected. 
 
    Dim objShell, objFSO, objEnv, strWorkFile, objFile 
    Dim arrData, intIndex, n, arrIPAddresses, arrParts 
 
    Set objShell = CreateObject("wscript.shell") 
    Set objFSO = CreateObject("scripting.filesystemobject") 
    Set objEnv = objShell.Environment("PROCESS") 
    If (objEnv("OS") = "Windows_NT") Then 
        strWorkFile = objEnv("TEMP") & "\" & objFSO.GetTempName 
        objShell.Run "%comspec% /c IPConfig >" & Chr(34) _ 
            & strWorkFile & Chr(34), 0, True 
    Else 
' WinIPCfg in batch mode sends output to filename WinIPCfg.out 
    End If 
    Set objShell = Nothing 
    Set objFile = objFSO.OpenTextFile(strWorkFile) 
    arrData = Split(objFile. ReadAll, vbCrLf) 
    objFile.Close 
    Set objFile = Nothing 
    objFSO.DeleteFile strWorkFile 
    Set objFSO = Nothing 
    arrIPAddresses = Array() 
    intIndex = -1 
    For n = 0 To UBound(arrData) 
        If (InStr(arrData(n), "IP Address") > 0) Then 
            arrParts = Split(arrData(n), ":") 
            If (InStr(Trim(arrParts(1)), "0.0.0.0") = 0) Then 
                intIndex = intIndex + 1 
                ReDim Preserve arrIPAddresses(intIndex) 
                arrIPAddresses(intIndex)= Trim(CStr(arrParts(1))) 
            End If 
        End If 
    Next 
    GetIPAddresses = arrIPAddresses 
End Function

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
ZknAuthor Commented:
Sorry for delay, I was out of country...I have tested the script and it is working great will assign the points to you. But can I request two modification with this script:
1) Can the script only log the computer names that 'Sophos is not installed' on. I do not need to log the results of the computer that already have 'Sophos installed', the list gets quite long.
2) Can we also have it check the machines that have 64 Bit OS installed, because the path is different for the 64 Bit machines "C:\ProgramFiles (x86)\Sophos". Currently it is logging these machines as not having Sophos installed.

Thank you so much
0
ZknAuthor Commented:
Can you please modify the script with the requested changes so that I can assign the points to you and close this post? Thank you
0
ZknAuthor Commented:
Please Help!!!!I would really appreciate if you can please update the script with the two modifications requested earlier...Thank you
0
merowingerCommented:
please try this
Option Explicit 
 
' Declare Variables 
Dim objFSO, objLogFile, objNetwork, objShell, strText, intAns 
Dim intConstants, intTimeout, strTitle, intCount, blnLog 
Dim strUserName, strComputerName, strIP, strShare, strLogFile, strSophos
 
' Define Variables 
strShare = "C:\" 
strLogFile = "IOfficeLogon.txt" 
intTimeout = 20 
 
' Instantiate objects 
Set objFSO = CreateObject("Scripting.FileSystemObject") 
Set objNetwork = CreateObject("Wscript.Network") 
Set objShell = CreateObject("Wscript.Shell") 
 
' Define variables 
strUserName = objNetwork.UserName 
strComputerName = objNetwork.ComputerName 
strIP = Join(GetIPAddresses()) 
 
' Log date/time, user name, computer name, and IP address. 
If (objFSO.FolderExists(strShare) = True) Then 
    On Error Resume Next 
    Set objLogFile = objFSO.OpenTextFile(strShare & "\" _ 
        & strLogFile, 8, True, 0) 
	On Error Goto 0
    If (Err.Number = 0) Then 

' Check if Sophos is installed         
		If Not objFSo.FolderExists("C:\Program Files\Sophos") Or Not objFSo.FolderExists("C:\Program Files(x86)\Sophos") Then  
			strSophos = "Sophos is not installed"  
		End If  
         


' Make three attempts to write to log file. 
        intCount = 1 
        blnLog = False 
        Do Until intCount = 3 
            objLogFile.WriteLine "Logon ; "  & Now & " ; " _ 
                & strComputerName & " ; " & strUserName & " ; " & strIP & " ; " &strSophos
            If (Err.Number = 0) Then 
                intCount = 3 
                blnLog = True 
            Else 
                Err.Clear 
                intCount = intCount + 1 
                If (Wscript.Version > 5) Then 
                    Wscript.Sleep 200 
                End If 
            End If 
        Loop 
         

        'On Error GoTo 0 
        If (blnLog = False) Then 
            strTitle = "Logon Error" 
            strText = "Log cannot be written." 
            strText = strText & vbCrlf _ 
                & "Another process may have log file open." 
            intConstants = vbOKOnly + vbExclamation 
            intAns = objShell.Popup(strText, intTimeout, strTitle, _ 
                intConstants) 
        End If 
        objLogFile.Close 
    Else 
        'On Error GoTo 0 
        strTitle = "Logon Error" 
        strText = "Log cannot be written." 
        strText = strText & vbCrLf & "User may not have permissions," 
        strText = strText & vbCrLf & "or log folder may not be shared." 
        intConstants = vbOKOnly + vbExclamation 
        intAns = objShell.Popup(strText, intTimeout, strTitle, intConstants) 
    End If 
    Set objLogFile = Nothing 
End If 
 
Function GetIPAddresses() 
' Based on a Michael Harris script, modified by Torgeir Bakken 
' Returns array of IP Addresses as output by IPConfig 
' Win98/WinNT have IPConfig (Win95 doesn't) 
' Win98/Win95 have WinIPCfg (WinNt doesn't) 
' Note: The PPP Adapter (Dial Up Adapter) is excluded if not connected (IP address will be 0.0.0.0) 
' and included if it is connected. 
 
    Dim objShell, objFSO, objEnv, strWorkFile, objFile 
    Dim arrData, intIndex, n, arrIPAddresses, arrParts 
 
    Set objShell = CreateObject("wscript.shell") 
    Set objFSO = CreateObject("scripting.filesystemobject") 
    Set objEnv = objShell.Environment("PROCESS") 
    If (objEnv("OS") = "Windows_NT") Then 
        strWorkFile = objEnv("TEMP") & "\" & objFSO.GetTempName 
        objShell.Run "%comspec% /c IPConfig >" & Chr(34) _ 
            & strWorkFile & Chr(34), 0, True 
    Else 
' WinIPCfg in batch mode sends output to filename WinIPCfg.out 
    End If 
    Set objShell = Nothing 
    Set objFile = objFSO.OpenTextFile(strWorkFile) 
    arrData = Split(objFile. ReadAll, vbCrLf) 
    objFile.Close 
    Set objFile = Nothing 
    objFSO.DeleteFile strWorkFile 
    Set objFSO = Nothing 
    arrIPAddresses = Array() 
    intIndex = -1 
    For n = 0 To UBound(arrData) 
        If (InStr(arrData(n), "IP Address") > 0) Then 
            arrParts = Split(arrData(n), ":") 
            If (InStr(Trim(arrParts(1)), "0.0.0.0") = 0) Then 
                intIndex = intIndex + 1 
                ReDim Preserve arrIPAddresses(intIndex) 
                arrIPAddresses(intIndex)= Trim(CStr(arrParts(1))) 
            End If 
        End If 
    Next 
    GetIPAddresses = arrIPAddresses 
End Function

Open in new window

0
ZknAuthor Commented:
It is not generating correct results, tested on couple of machines with Sophos installed but is logging it as "Sophos not installed". I think the following needs to be adjusted:
If Not objFSo.FolderExists("C:\Program Files\Sophos") Or Not objFSo.FolderExists("C:\Program Files(x86)\Sophos") Then  

Thank you
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
Anti-Virus Apps

From novice to tech pro — start learning today.