Run your asp files on a regular basis.

Source: Internet
Author: User
Tags blank page
At a certain time, it is necessary to regularly run an ASP file to execute a task. For example, a factory needs to collect the readings of all electric meters at nine o'clock a.m, of course, this should be connected to various electric meters through in SQL. Now we use an ASP file to concentrate the reading of tables in SQL into ms SQL.

You may see a variety of methods to run ASP files on a regular basis, but now I want to talk about a simple method that can be simply implemented by using scheduled tasks.

First, you need to write a JS or vbs file to call all your executed ASP files. The following is the code for JS and vbs files. You can select one of them and the execution result is the same.

Vbs code -------------------------
'Code by mini-ho aston314@sohu.com
'Create an instance of IE
Dim IE
Set Ie = Createobject ("internetexplorer. application ")

'Run your url

Ie. navigate ("http://www.blueidea.com /")
Ie. Visible = 1

'Clean up...
Set Ie = nothing
---------------------------------

You can get any name, but the suffix must be vbs. Here we name it do. vbs.

JS Code ---------------------------
// Code by Xiao He aston314@sohu.com
// Create the HTML message to display.
VaR html = "";
HTML + = "<HTML> HTML + = "<font face = verdana> </font> ";
HTML + = "</body>

// Create Internet Explorer Object
Ie = new activexobject ("internetexplorer. application ");

// Define how the window shocould look
Ie. Left = 50;
Ie. Top = 50;
Internet Explorer. Height = 510;
Ie. width = 470;
Ie. menubar = 0;
Ie. toolbar = 0;

// Set the browser to a blank page
Ie. navigate ("http://www.blueidea.com /");

// Show the browser
Ie. Visible = 1;

// Open a stream and write data.
// Ie.doc ument. open;
// Ie.doc ument. Write (HTML );
// Ie.doc ument. close;
------------------------------------

You can also use any name, but the suffix must be Js. Here we name it do. js.

The code in the file is not described here.

You just need to replace all the http://www.blueidea.com/in the above file with the URL of the ASP file you want to execute. Here is the URL address, not the absolute address.

Then open the Windows Task Plan, select the location of the above do. js or do. vbs file, and set the execution time, just like selecting any executable file.

Then the ASP file can be scheduled and run by the task.

As said at the beginning, the task plan can execute this ASP file at AM and collect the meter readings into the ms SQL.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.