At a certain time, an ASP file needs to be run regularly to perform a task. For example, a factory needs to collect the readings of all electric meters at 9 o'clock in the morning. Of course, this needs to be connected to each electric meter through IN SQL. We are now using An ASP file re-aggregates the table readings in IN SQL into MS SQL.
You may have seen many ways to run ASP files regularly, but what I am going to talk about now is a simple method, which can be easily implemented using scheduled tasks.
First, you have to write a js or vbs file to call all the ASP you execute. Below is the code for js and vbs files. You can choose either one, and the execution effect will be the same.
vbs code-------------------------
'CODE BY Xiaohe [email protected]
'Create an instance of IE
DI
Set IE = CreateObject(InternetExplorer.Application)
'Run your URL
ie.navigate(http://www.vevb.com/)
ie.visible=1
'Clean up...
Set IE=Nothing
----------------------------------
You can give it any name, but the suffix must be vbs. Here we name it do.vbs.
js code-----------------------------
var html = ;
html += <html><head><title>Run window</title></head><body>;
html += <font face=verdana></font>;
html += </body></html>;
// Create Internet Explorer Object
ie = new ActiveXObject(InternetExplorer.Application);
// Define how the window should look
ie.left = 50;
ie.top = 50;
ie.height = 510;
ie.width = 470;
ie.menubar = 0;
ie.toolbar = 0;
// Set the browser to a blank page
ie.navigate(http://www.vevb.com/);
// Show the browser
ie.visible=1;
// Open a stream and write data.
//ie.document.open;
//ie.document.write(html);
//ie.document.close;
----------------------------------
You can also give it any name, but the suffix must be js. Here we name it do.js.
The code in the file will not be explained here.
Just replace all http://www.vevb.com/ in the above file with the URL address of the ASP file you want to execute. This is a URL address, not an absolute address.
Then open the WINDOWS task plan, select the location of the above do.js or do.vbs file just like selecting any executable file, set the execution time, etc., and confirm.
Then this ASP file can be run regularly by the task schedule. It's simple.
As mentioned at the beginning, the task plan can execute this ASP file at 9 o'clock in the morning and collect the meter readings into MS SQL.