What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

exe sensor

Votes:

0

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



3 Replies

Votes:

0

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

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



Votes:

0

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]




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.