Mohammedz.com

For Linux and Shell scripting.

How to Create Scheduled Tasks for .aspx Files

28 Comments


You can create scheduled tasks for .aspx files by scheduling your .aspx files to run using iexplore.exe:

Start –> Control panel –> Scheduled Tasks –> Add scheduled task

Then, browse for your .aspx file and select it.

After creating scheduled task, go through Start –> Control panel –> Scheduled Tasks and select the properties of the newly created task.

Suppose, you want to schedule http://192.168.1.0/ScheduleMe.aspx, then the “run” field should looks like:

“C:\Program Files\Internet Explorer\IExplore.exe” http://192.168.1.0/ScheduleMe.aspx

By default, IExplore.exe opens a browser each time it runs. In order to close the browser you may have to schedule another task. Here is a very simple task to close the IE browser:

taskkill /IM iexplore.exe

Open your notepad and save the file as .bat (say IEkill.bat) after entering the line above. Schedule this to run after 5 or 10 minutes.

Advertisements

28 thoughts on “How to Create Scheduled Tasks for .aspx Files

  1. Where do we run “taskkill /IM iexplore.exe”?

    C:\Documents and Settings\Meher>taskkill /IM iexplore.exe
    ‘taskkill’ is not recognized as an internal or external command,
    operable program or batch file.

  2. Taskkill command will work for Windows 2003. You can find its usage from microsoft site:
    http://technet.microsoft.com/hi-in/library/bb491009(en-us).aspx

    Which OS you are using?.
    Try “kill” or “pskill.exe”

    If none of them works, download process.exe from the url below. That should help you to view, kill, or suspend any program. (sorry, I didn’t try it out :-P)
    http://www.beyondlogic.org/consulting/processutil/processutil.htm

    Regards,
    Mohammed.

  3. In my opinion the better approach is to kill window process from within code behind.
    Just include this code as a very last step in your ScheduleMe.aspx

    Dim ProcName As String = “iexplorer”
    Dim procList As Process() = Process.GetProcesses()

    For Each p As Process In procList
    If p.MainWindowTitle.ToString().Contains(“ScheduleMe.aspx”) = True Then
    p.Kill()
    Exit Sub
    End If
    Next

  4. Do you know of any way to do this for a user that is not currently logged in? I’m trying to do this on a server and there’s no permanant account logged in.

  5. mohammednv,
    well done
    keep it up
    mind blowing

  6. Thank you guys for you valuable comments.

    Let me know if you have any suggestions to make it more useful & beautiful :-P.

  7. hi, i wanted to schedule this :
    http://localhost:1529/LAMS/Administrator/autoEmail.aspx

    and i edited the run field to this :
    C:\Program Files\Internet Explorer\iexplore.exe” http://localhost:1529/LAMS/Administrator/autoEmail.aspx

    yet the scheduled task could not run, with the status at “Could not start”. can anybody point out the error to me ? i need it urgently and have to submit it by tml. any help would be greatly appreciated. thanks!

  8. Hi lynn,

    Double check the paths given and check if the url is working within a browser. Also, I see a double quote missing in the run field. Either remove the existing one or make it like:

    “C:\Program Files\Internet Explorer\iexplore.exe” http://localhost:1529/LAMS/Administrator/autoEmail.aspx

    Try this and let me know what happens 🙂

  9. Hi,

    I am trying to set a password to work with my .aspx. I am assuming this will be an ADMIN username and password. When I set it, all works well. When the task runs, it opens up a page with username and password (I set up through IIS to not open page anonymously) and does not do anything.

    If I browse to the page and enter the credentials from another computer outside the network, it works fine. I enter the username as DOMAIN\admin. From within the network, what credentials should I be entering. DOMAIN\admin or admin.

    Please suggest. Thanks.

  10. Hi Sunny,

    From what I understand from your comments, you can simply use ‘admin’ as username (both in & outside the network). If that didn’t work, double check the authentication method you have selected via IIS.

    I believe you are accessing the page in the same way from in and outside the network.

  11. hello sir,
    i want to run this application first on localhost, but whenever i select my file from my project, it is not showing path as shown by you in Run field.
    it just giving path of my file like c:/project1/abc.aspx
    and when it runs application it opening file in visual studio
    can you please tell me where i am going wrong

    thanks

  12. Edit the *Run* field to look like:
    “C:\Program Files\Internet Explorer\IExplore.exe” c:/project1/abc.aspx

    Before scheduling this, try to execute it from command prompt. It should work for you ;).

    Let me know how it goes.

  13. hello Mohammed

    yes it works,

    thanks

  14. Hello ,

    It creating problem on server, when i tried it on localhost it closes the application on completion very well. But on server it doesn’t close the application.
    Can you please tell me what problem is there?

    Thank You

  15. To kill process i have written following code
    Process[] processlist = Process.GetProcesses();
    foreach (Process p in processlist)
    {
    Response.Write(p.MainWindowTitle+””);
    if (p.MainWindowTitle.Contains(“testschedular”) == true)
    {
    p.Kill();
    }

    }

    where testschedular is name of my file , also i have put the same title

    Thanks

  16. Hai,

    I shedule an aspx page, Everything works when i was loged in , But it not working when i logged out…, task was running but it doesnt open a internet explorer ..

  17. Rups,

    I guess you have tried the taskkill command I explained in the very first post.

    Anyway, thanks for posting a new method to do it.

  18. Mahesh,

    Make sure *run only if I logged in* is NOT checked in the properties of Scheduled task.

  19. That was not checked, Actually the tasks runs but the page was not browsed..

  20. Hello ,
    My aspx page run successfully form scheduler task but after one hour it will show me error as
    The page cannot be displayed

    I have to update some database records from my first domain to another domain , so my page have to run at least for two hours to update all records from my first domain database to another domain db.
    when i run my aspx page manually through browser then it successfully complete and take approximately two hours.
    But when i try to run the same page from Window Scheduled task then it run page and show error after exactly one hour with error as The page cannot be displayed .
    I have checked everything and also search on the net but did not get any post related this , so i little confuse whether this is problem with my scheduler or anything else . Plz reply if you have any idea why this is happening.
    Is there any limitation with Scheduled task for aspx page for one hour only.
    my os is window 2003 server.

    Thanks in Advance
    Jitendra

  21. Jitendra,
    It’s a strange behavior !!! As the script works fine when you run manually, there shouldn’t be any problem with code or internet explorer. I’m sure, Winsows task scheduler can be used to run tasks which last for many days ;). I don’t think there is any special settings for .aspx codes :-D.

    What I suspect is, there is an option in the task scheduler which kills the task if it runs for more than what you specify there. Double check that you haven’t limited it for 1 hour. You can see this option under *task->properties->settings->stop the task if runs for….*.

  22. It is a helpful resource. Thank you

  23. Much better way…create a vbscript file sendmail.vbs and put in the following code :-

    ‘On Error Resume Next

    Dim objRequest
    Dim URL

    Set objRequest = CreateObject(“Microsoft.XMLHTTP”)

    URL = “http://www.mydomain.com/file.aspx”

    objRequest.open “POST”, URL , false

    objRequest.Send

    Set objRequest = Nothing

  24. I have a web page that I want to open every night and click a button, is there a way to make the scheduled task then submit a form?

  25. hi all

    I tried to create the Scheduled task (before visiting this page) and was getting irritated for the last 5 days for not able to execute a simple page that stores Time stamp in MS SQL DB when ever the file is executed.

    Thanks for Mohammed ji’s help feeds details that executed the file.

  26. thank friend, it is very helpful me.

  27. Hi,
    Here how can i pass username and password for my website?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s