New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


exe sensor

Votes:

0

Your Vote:

Up

Down

Strange issue , we have created several exe sensors which work fine. 2 sensors that we have created lately use

System.Windows.Forms.WebBrowser object

within console exe. Console tests fine in command window, but when added as a sensor following event does not work private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)

Is there some level of security that prevents some events from executing.

We are using 2012 window server , program is a simple console app using C# 4.0 framework the only difference is we are using web browser control .

exe prtg sensor

Created on Oct 4, 2016 9:55:11 PM by  tmazur (0) 1



3 Replies

Votes:

0

Your Vote:

Up

Down

Any specific user you're executing this with? Does this user have been logged in and started IE at least once (and configured it)?

Created on Oct 5, 2016 11:24:03 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

You will need to capsulate the web browser control in its own class.
Code snippet in VB:

#Region " Classes "
    Private Class Browser
        Private Shared completed As Boolean = False
        Private Shared wb As WebBrowser

        Shared Function Main(ByVal url As String) As String
            completed = False
            wb = New WebBrowser()
            wb.ScriptErrorsSuppressed = True
            RemoveHandler wb.DocumentCompleted, AddressOf wb_DocumentCompleted
            AddHandler wb.DocumentCompleted, AddressOf wb_DocumentCompleted

            wb.Navigate(New Uri(url))
            Dim maxWait As Integer = 150  '// wait for a maximum of 15 seconds

            While Not completed AndAlso maxWait > 0
                maxWait -= 1
                Application.DoEvents()
                Thread.Sleep(100)
            End While

            If maxWait = 0 Then Return ""
            Application.DoEvents()
            Return wb.DocumentText
        End Function

        Shared Sub wb_DocumentCompleted(ByVal sender As Object, ByVal e As WebBrowserDocumentCompletedEventArgs)
            Thread.Sleep(1000)
            completed = True
        End Sub
    End Class
#End Region

'// and call it like this
Dim content As String = Browser.Main("http://prtgtoolsfamily.com/")

Created on Oct 7, 2016 11:48:54 AM by  PRTGToolsFamily [prtgtoolsfamily.com] (12,725) 3 4



Votes:

0

Your Vote:

Up

Down

Thanks! :)

Created on Oct 7, 2016 11:51:55 AM by  Stephan Linke [Paessler Support]

Last change on Oct 7, 2016 11:56:36 AM by  Stephan Linke [Paessler Support]



Please log in or register to enter your reply.


Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.