Link to home
Start Free TrialLog in
Avatar of Larry Brister
Larry BristerFlag for United States of America

asked on

WinServer 2003

I need to set up a scheduled task that will open a internet explorer (in IE7) url at a specific time and close it automatically 2 minutes later.
Avatar of Joel Coehoorn
Joel Coehoorn
Flag of United States of America image

This should work, but it will start the default web browser, which may not always be IE.
        Dim p As Process = Process.Start("http://www.google.com")
        If Not p.WaitForExit(120000) Then p.Kill()

Open in new window

Avatar of Larry Brister

ASKER

jcoehoorn,
Is this a vb script I open?
No.  Since the question is in the VS.Net and .Net Editors zones it's VB.Net code, and requires the .Net framework.  Here's a more complete listing.  Just create a new console app, replace the contents of the default Module1.vb file with this (with your desired url in the appropriate place), build it, and schedule the created .exe file for your desired time:
Module Main
    Sub Main()
        Dim p As Process = Process.Start("http://www.google.com")
        If Not p.WaitForExit(120000) Then p.Kill()
    End Sub
End Module

Open in new window

jcoehoorn:
  Ahhhhhhhh.....

Thanks.  I'll do that.  I'm a web developer and din't think about where the answer was coming from.
jcoehorn,
  The application(s) opened but errored on the close part.

Error message attached...
EventType clr20r3, P1 pages.exe, P2 1.0.0.0, P3 47b1f8d1, P4 pages, P5 1.0.0.0, P6 47b1f8d1, P7 11, P8 c, P9 system.nullreferenceexception, P10 NIL.
 
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Joel Coehoorn
Joel Coehoorn
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great job.  Thanks