Windows Service - Opening IE window

Invoke

New member
Joined
Oct 27, 2003
Messages
1
Hi everyone,

Ive created a windows service with a timer which opens a IE browser window targeted at a specific page/script. It works if I run the executable itself, however when I install it as a service using InstallUtil and then manually start the service it does not work.

Any thoughts, suggestions or fixes would be really helpful.

Code from the service.vb file is below.

Thanks!


Code:
    Protected Overrides Sub OnStart(ByVal args() As String)
         Add code here to start your service. This method should set things
         in motion so your service can do its work.
        Timer1.Enabled = True
    End Sub

    Protected Overrides Sub OnStop()
         Add code here to perform any tear-down necessary to stop your service.
        Timer1.Enabled = False
    End Sub

    Set variables for use in the Tracker
    Public Explorer As SHDocVw.InternetExplorer

    Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
        Explorer = New SHDocVw.InternetExplorer
        Explorer.Visible = True
        Explorer.Navigate("http://www.microsoft.com")
    End Sub
 
you need to take a look at the System.Diagnostics.Process class to open your IE window really. ( no need to use SHDocVw.InternetExplorer to open a new IE window ) eg:
Code:
System.Diagnostics.Process.Start("IEXPLORE.EXE", "http://www.microsoft.com")
/// open a new instance of IE and navigate to your chosen site.
 
Its highly likely that it is working but youre simply not noticing. Windows services run on the SYSTEM or Network accounts. Their desktops are separate from yours, and any window created will only be displayed in their context.
 
Back
Top