Results 1 to 4 of 4

Thread: Windows Service - Problem starting IE

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2003
    Posts
    7

    Windows Service - Problem starting IE

    Hi everyone,

    I've 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

  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    you really dont need to use " SHDocVw.InternetExplorer " to open a new internet explorer window. take a look at the " System.Diagnostics.Process " , eg:
    VB Code:
    1. System.Diagnostics.Process.Start("IEXPLORE.EXE", "http://www.microsoft.com")
    2. [COLOR=green]'/// this will open a new instance of internet explorer and navigate to [url]http://www.microsoft.com[/url][/COLOR]
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2003
    Posts
    7
    Thanks for the response. I'll give it a shot now.

  4. #4

    Thread Starter
    New Member
    Join Date
    Sep 2003
    Posts
    7
    Alright, I've got the service working and opening IE as a process thanks to your advice. I can see it in the task manager process list. However it's not doing the processing at the website that I'm calling.

    The idea behind this script is the regular calling of a PHP web page that does some processing on a database. I'm 100% sure that the web script works because I can open the service as a normal EXE and it opens a browser window, goes to the correct page and performs the processing.

    So I'm now wondering if web page execution is only done when a browser window is open.

    Revised code is below.
    Code:
        Protected Overrides Sub OnStart(ByVal args() As String)
            Timer1.Enabled = True
        End Sub
    
        Protected Overrides Sub OnStop()
            Timer1.Enabled = False
        End Sub
    
        Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
            System.Diagnostics.Process.Start("IEXPLORE.EXE", "http://spike/development/iproject_1_0_8/automation/ichecker.php")
        End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width