利用计划任务实现asp定时任务
首先,你要写一个js或者vbs文件来调用你所有执行的ASP。下面是js和vbs文件的代码,你可以任选一个,执行效果是一样的。
vbs代码拷贝框
‘Create an instance of IE
Dim IE
Set IE = CreateObject(“InternetExplorer.Application”)
’运行你的 URL
ie.navigate(“http://w3e.cn/”)
ie.visible=1
‘Clean up…
Set IE = Nothing
你可以取任何名称,但后缀名一定要是vbs,在这里我们取名do.vbs。
js代码拷贝框
// Create the HTML message to display.
var html = “”;
html += “
html += ““;
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://w3e.cn/”);
// Show the browser
ie.visible=1;
// Open a stream and write data.
//ie.document.open;
//ie.document.write( html );
//ie.document.close;
你也可以取任何名称,但后缀名一定要是js,在这里我们取名do.js。
这里不对文件中的代码进行解说。
只要把上面文件中的所有 http://w3e.cn/ 换成你要执行的ASP文件的URL地址就可以了。这里是URL地址,而不是绝对地址。
然后打开 WINDOWS 的任务计划,就象选择任何可执行文件一样选择上面一个do.js或者do.vbs文件所在的位置,设定执行时间等,确定就可以了。
然后这个ASP文件就可以被任务计划定时的运行了,简单吧。