让服务器每天自动运行asp-script [英] Make server automatic run asp-script every day

查看:22
本文介绍了让服务器每天自动运行asp-script的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以创建一个打开 firefox、运行网站然后再次关闭 firefox 的批处理文件?

Is it possible to create a batch-file which opens firefox, runs a website and then closes firefox again?

类似:

@echo off
start firefox http://.....

这是我卡住的地方...网站加载完成后需要再次关闭firefix.

This is where I am stuck... It needs to close firefix again when the website is finished loading.

它用于每晚 23:59 运行维护脚本.该脚本基于本地,但不使用服务器就无法运行 asp 文件,因此我将其作为网站放置.

It is used to run a maintenance-script every night at 23:59. The script is based locally, but one cannot run a asp-file without using a server, so I have placed it as a website.

推荐答案

改编自我多年前在 aspfaq.com 上写的一篇文章.

使用 AT 命令和 Windows 脚本主机(或更基本的任务调度程序)以特定间隔调度 VBS 文件.

Use the AT command and Windows Scripting Host (or the more rudimentary task scheduler) to schedule a VBS file at certain intervals.   

首先,将 ASP 更改为 VBS 文件.这是通过 (1) 将扩展名更改为 VBS 来实现的;(2) 将所有 Server.CreateObject 调用更改为 CreateObject;(3) 删除所有 <%%> 定界符和任何浏览器指定的代码(例如,response.write 语句或客户端 HTML).我没有遇到任何进一步的并发症,而是 YMMV.

First, change the ASP to a VBS file. This is accomplished by (1) changing the extension to VBS; (2) changing all Server.CreateObject calls to CreateObject; and, (3) removing all <%%> delimiters and any browser-destined code (for example, response.write statement or client-side HTML). I didn't run into any further complications, but YMMV.   

您将 VBS 文件存储在文件系统中,并使用 AT 命令对其进行调度(这实际上是使用 Windows 的调度服务来调度其执行).在命令提示符下,您可以单独使用 AT 来查看当前计划中的任务列表.你可以使用 AT/?找出它所有的语法可能性.

You store the VBS file in the filesystem, and use the AT command to schedule it (this actually schedules its execution with Windows's schedule service). At a command prompt, you can use AT by itself to see a list of tasks currently in the schedule. You can use AT /? to find out all its syntax possibilities. 

例如,要让文件在每个工作日上午 9:00 运行,我启动这个批处理文件(第一行清除现有条目):

For example, to get a file to run every weekday at 9:00 am, I launch this batch file (the first line clears existing entries):     

at /delete /y 
at 9:00 /every:m,t,w,th,f d:
etsharedgetdata.vbs      

注意不涉及网络服务器;该文件是通过文件系统直接访问的.一旦我克服了用户必须登录"和重新启动时必须重置任务"的障碍(我认为这两个问题都是我们无法控制的特定机器的问题),一切都在运行对于我来说足够了.

Notice there is no web server involved; the file is accessed directly through the file system. Once I got over the "a user has to be logged in" and "the tasks have to be reset when rebooted" hurdles (both of which I believe are problems with the particular machine that is not under our control), all has been running fine for me. 

有关使用 WSH、CDONTS 和任务计划程序定期发送电子邮件的示例,请参阅 知识库#221495.

For an example of using WSH, CDONTS and the Task Scheduler to send out e-mails on a regular basis, see KB #221495. 

如果您所做的只是在 SQL Server 中进行数据库工作,您可能会考虑使用作业.这将允许您将作业的所有处理保留在您的数据库中,并防止与多个系统、连接和将 ASP 代码调整为非 ASP 行为相关的复杂情况.

If all you are doing is database work in SQL Server, you might consider using a job. This will allow you to keep all the processing of the job within your database, and prevent the complications associated with multiple systems, connections, and adapting ASP code to be non-ASP-like in behavior.

这篇关于让服务器每天自动运行asp-script的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆