opening IE from a windows service

jeffchs

Newcomer
Joined
Jun 17, 2003
Messages
17
Hi all, I'm running into an issue here. I have a windows service that checks for a condition and if the condition is met I want to open a certain web page in internet explorer. I can start the process, but a window for IE doesn't open. Here is my code:


ProcessStartInfo si = new ProcessStartInfo();
si.FileName = "C:\\Program Files\\Internet Explorer\\iexplore.exe";
si.Arguments = "www.microsoft.com";
si.UseShellExecute = false;
si.RedirectStandardOutput = true;
si.WindowStyle = ProcessWindowStyle.Maximized;

Process.Start(si);


Any help would be appreciated!

Jeff
 
Windows services typically have no user interaction when running and as such any applications spawned do not appear.

I *think* that if you configure your service to 'Interact With Desktop' under Programs->Administrative Tools->Services.
right click the service and go to the tab 'Log On' it might work.

Out of interest what are you trying to achieve? I personally would find it very annoying if a background service kept launching browser sessions while I was working.
 
My Sys Admin needs a way to keep track of all users passwords for quick access rather than obtaining them from the server each time. The service I am working on checks our list at logon to see if the user's password is expired (by our standards), if so, it will redirect them to an asp.net web page to change their password and update our list simutaneously. This is a stricly in house service, just to make things easier on our IT department.

If I go into the log on settings in service manager I can check the "Allow service to interact with desktop" and that allows the window to open but then I lose the ability to obtain the user name because it is running under the system account.

Is there any way to obtain the a logged on users identity from a service running under the system account?

Jeff
 
Last edited:
Could you possibly have two services? Have the one service do your validation as is and the second service could be called by the first service to pop up the window.
 
I thought about doing two services but then realized that it would only check the user who the first service runs as. if someone else were to logon at a machine whose primary user has an expired password, it would direct them to change their password wether it was necessary or not. I'm hoping there is some way to check for the current user from the system account.

Maybe I'll just ditch this approach and come at it from another angle. I guess I could always create a program that runs in the background that just starts when the user logs on. I was hoping to do it in a service so it was completely transparent to the user.

Thanks for the responses.
 
here's an example i built to help someone on the other vb forum , it opens 5 instances of internet explorer , all with different urls.
Visual Basic:
Private pr(5) As Process
'//// in main part of form , so it's available to all subs^^^
'////////////

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim strUrl(5) As String
        Dim i As Integer

        strUrl(1) = "http://chat.msn.com" : strUrl(2) = "http://google.com" : strUrl(3) = "http://yahoo.com"
        strUrl(4) = "http://www.visualbasicforum.com/index.php?" : strUrl(5) = "http://www.xtremedotnettalk.com/index.php?"
        Try
            For i = 1 To 5
                pr(i) = pr(i).Start("IEXPLORE", strUrl(i))
                ListView1.Items.Add((pr(i).Handle.ToInt32)) '///add hwnd to listview.
                System.Threading.Thread.Sleep(500)'/// pause for half a second.
            Next
        Catch
            MessageBox.Show(Err.Number & " " & Err.Description, "Error!")
        End Try

    End Sub

    Private Sub ListView1_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListView1.DoubleClick
        Dim i As Integer = ListView1.SelectedItems(0).Index + 1
        pr(i).CloseMainWindow() '/// close the instance of process.
        ListView1.Items.Remove(ListView1.Items(i - 1)) '/// remove process from list.
    End Sub
hope this helps.
 
Back
Top