A very common ASP question: How to execute web pages in a timed workflow?, This question is mostly because administrators may use an ASP web page to perform database maintenance actions, such as backup..., etc., in Windows NT The platform has a way to do workflow, that is, AT command + Schedule service, but unfortunately, you do not have the rules to execute the ASP web page in the Command-Line command
Of course you can execute IE in the command column and tell it the web page that it requires execution, for example: c:/program files/internet explorer/iexplore.exe http://localhost/mypage.asp, however, this is definitely not most website management The method that users want is because this requires opening the browser, spending a lot of system resources, No Good! In addition, there is another disadvantage, that is, there is a timeout (Timeout) for executing ASP web pages, if you want to perform a lot of process work , You may have to change the Timeout time, wow! Too trouble! No good!
In this article, we will introduce a solution using WSH (Windows scripting Host).
Installation of WSH
Windows 98, Windows 2000, IIS 4.0 already includes WSH, WSH is included in IE 5.0 version. If you are a Windows 95 user, you can download individual installers from Microsoft website http://www.microsoft.com/msdownload/vbscript/ scripting.asp .
example
Suppose you have an advertising dialing system now, and you want to automate the checking of the ad expiration date. This is done in the early morning of every day, that is, when an ad expires, change its advertising status to deactivate. Let's take a look first. Data table AdInfo field.
AdId Ad Code Int
AdName Advertising nameVarChar(64)
ValidToDate Ad Expiry DateDateDate
AdStatus Ad Status Int (0 is deactivated, 1 is carried out)
Let's see how to do ASP first
Next, let’s take a look at how to use WSH. Basically, the writing method is the same as ASP except that the extension saved is .vbs without adding the ASP delimiter.
Since asp.dll is not used, object mode without ASP is not applicable
Use WSH to perform scheduled workflows
2001-07-15・・Unknown・・
Previous Page 1 2 3
'Do not use Server.CreateObject
Set oConn = CreateObject(Adodb.Connection)
oConn.Open YourConnString
sSQL = update AdInfo set AdStatus=0 _
& where ValidToDate<=' & Date & '
oConn.Execute(sSQL)
oConn.Close
Set oConn = Nothing
Save as c:/scripts/updateadstatus.vbs, there are two versions of WSH, one is the window version (wscript.exe) and the other is the command version (cscript.exe). In this example, we will use (cscript.exe). You can execute under the DOS command column:
c:/scripts/updateadstatus.vbs
Then you can go to Query Analyzer to check whether the data is updated. In actual applications, it is recommended that you use this file to distinguish work in different periods. For example, I will create a batch file called dailytask.bat to perform all the The daily routine work, so I just need to put all the scripts that should be executed every day into this batch, and then use AT Command or SQL Server Agent to execute dailytask.bat regularly.
It is strongly recommended to use SQL Server Agent, which will be more efficient and stable than using AT Command! Setting up SQL Server Agent You can execute Enterprise Manager, and you will see such a picture after expanding.
Click Jobs on the right mouse button and select New Job.
Select Step Press New.
Specify Step Name and Type Please select Operating System Command and set the executed Command.
Select Schedule to set your process.