Click here to Skip to main content
11,920,772 members (56,733 online)
Click here to Skip to main content
Add your own
alternative version


7 bookmarked

Scheduled Task in Middle Trust Enviroment

, 11 Dec 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
Explains how to setup scheduled task on Windows hosting through Plesk CP


I always wondered how to run scheduled tasks on windows hosting. For example, under the Plesk control. At first look, everything is ok. We have scheduled task and "command line" for it. But what to write there in the command line? This is the big question.

Somebody says - no problem, I'll write "iexplore"

But I'm wondering, who closes this Internet Explorer process on server, and what if you are going to run this task every 5 minutes?

I don't like this way. So, where is the answer? Answer is inside VB. All that we need is to create VB script and run it inside command string.
This script creates Microsoft.XMLHTTP instance (yes, we don't need to check anything like in AJAX deal, because we are certainly in Microsoft environment). And using this instance requests your ASPX page to do the entire job.

So, when I've asked my hosting support, how to call aspx page scheduled - they said - this is impossible. Call PHP page and there request your ASPX if you want. No, thanks.

Using the Code

Plesk screen... to add scheduled task. "Path to executable" should be set to ABSOLUTE path to vbs file on server. Where can you get this path... First of all, your hoster should give you information about your site's folder. If not, write a simple aspx page with Server.MapPath("my.vbs"); So, what's inside the VB file?

Call RunIt()
Sub RunIt()
        'Let the script to finish on an error.

        On Error Resume Next
        Dim RequestObj
        Dim URL
        Set RequestObj = CreateObject("Microsoft.XMLHTTP")
        'Request URL... 

        URL = ""
        'Open request and pass the URL "POST", URL , false
        'Send Request


        Set RequestObj = Nothing
End Sub        

That's all. And you can run the scheduled task. Plesk is just for example... you can use Windows schedule if you've terminal access to the server.

Points of Interest

This is a simple thing, but I better say "trick" that can help you to solve the problem of scheduled task.


Originally posted on my site.

Works fine on several sites for daily content updates.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Dmitry Salko
Web Developer
Ukraine Ukraine
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralThis worked for me Pin
Benjano13-Jul-12 2:15
memberBenjano13-Jul-12 2:15 
QuestionPath? Pin
xirc_za17-Jul-09 13:13
memberxirc_za17-Jul-09 13:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.151120.1 | Last Updated 11 Dec 2007
Article Copyright 2007 by Dmitry Salko
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid