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.