Timing a very common ASP question: "How does a timed workflow execute a Web page?", most of the questions are asked because administrators may use an ASP Web page to perform database maintenance actions, such as backup ... And so on the Windows NT platform there is a way to do the work process, that is at instruction + Schedule service, but unfortunately you don't have the means to execute ASP Web pages in command columns (command-line)
Of course you can execute IE on the command line and tell it the Web page that you want to execute, for example: C:\Program Files\Internet Explorer\iexplore.exe http://localhost/mypage.asp, however, This is definitely not the way most site managers want to go, because it has to be browser-enabled, and it costs a lot of system resources, no good! In addition, there is a drawback, that is, the implementation of ASP Web pages have more than time (Timeout), if you want to perform a lot of process work, you may want to change Timeout time, wow! Too much trouble! No good!
In this article, you will be presented with a solution that uses WSH (Windows scripting Host).
Installation of WSH
Windows, Windows, IIS 4.0 already contains WSH, WSH is included in IE 5.0, if you are a Windows 95 user, you can download individual installers to the Microsoft Web site http://www.microsoft.co M/msdownload/vbscript/scripting.asp.
Example
Suppose you now have an ad-dial system that you want to check the ad expiration date of this work automatically every morning, that is, when an ad expires, it will change its advertising status to disable, we first look at the table adinfo fields.
Adid AD Code Int
Adname Advertising name VarChar (64)
Validtodate AD Expiration Date DateTime
adstatus AD Status Int (0 is inactive, 1 is active)
Let's see what the ASP does.
Next look at how to use WSH, basically with the ASP's writing is the same except the need to add ASP separator disk extension is. vbs.
The absence of an ASP's object pattern does not apply because Asp.dll is not used
Using WSH as a timing work flow
2001-07-15 Unknown ·
Previous Page 1 2 3
' Please 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, WSH has two versions, one for the window version (Wscript.exe), one for the command column (cscript.exe), in this example we will use (cscript.exe), you can in do The S command column executes:
C:\>cscript C:\scripts\updateadstatus.vbs
Then you can go to query Analyzer to check whether the data is updated, in practical applications, we recommend that you use batch this file to distinguish between different hours of work, like that I will create a batch file called Dailytask.bat to perform all the daily routine work, so that, All I need to do is put all my daily script into this batch file, and then use the at Command or the SQL Server Agent to perform Dailytask.bat daily.
It is highly recommended that you use the SQL Server Agent, which is more efficient and stable than using the at Command! Configure SQL Server Agent you can perform Enterprise Manager, and you will see this when you start.
Right click Jobs, select New Job.
Select step to press New.
Specify step Name, Type Select the operating System command, and set the command to execute.
Choose Schedule to set your process.