|
|
|||||||||
|
|||||||||
|
|||||||||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
|
|
#1
|
|||
|
|||
|
Run ASP script as a scheduled job?
I have the following script that I have successfully been able to run in a web application. How can I transfer this into a .vbs and have it run as a scheduled job on my server? I know I can run Cscript as a timed job from a batch file, but I dont know if this code will work as a .vbs What am I missing or what needs to be converted?
Here is my code in ASP... I'm a newbie so be nice. Code:
<%
Dim Conn, Rs2, rs, pager
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open xDb_Conn_Str
set pager = Conn.Execute ("SELECT count(*) AS rc3 FROM WEBASGN_FULL GROUP BY CFSNUM HAVING count(*) > 5")
' Set up Record Set
Set rs = Server.CreateObject("ADODB.Recordset")
rs.CursorLocation = 3
rs.Open sSql, conn, 1, 2
nTotalRecs1 = rs.RecordCount
If nDisplayRecs <= 0 Then ' Display All Records
nDisplayRecs = nTotalRecs1
End If
nStartRec = 1
SetUpStartRec() ' Set Up Start Record Position
if not(pager.BOF and pager.EOF) then
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
Set Flds = iConf.Fields
' send one copy with Google SMTP server (with autentication)
schema = "http://schemas.microsoft.com/cdo/configuration/"
Flds.Item(schema & "sendusing") = 2
Flds.Item(schema & "smtpserver") = "smtp.gmail.com"
Flds.Item(schema & "smtpserverport") = 465
Flds.Item(schema & "smtpauthenticate") = 1
Flds.Item(schema & "sendusername") = "xxxxx"
Flds.Item(schema & "sendpassword") = "xxxxx"
Flds.Item(schema & "smtpusessl") = 1
Flds.Update
With iMsg
.To = "xxxxx"
.From = "xxxxx"
.Subject = "PGR - Calls have reached a critical threshold"
.HTMLBody = "Check BB for details<br><br>"
.Sender = "xxxxx"
.Organization = "xxxxx"
.ReplyTo = "xxxxx"
Set .Configuration = iConf
SendEmailGmail = .Send
End With
set iMsg = nothing
set iConf = nothing
set Flds = nothing
Response.Redirect("WEBASGN_FULLlist_threshhold.asp")
%>
<% End If %>
|
|
#2
|
||||
|
||||
|
It should work as a vbs script fine in windows scheduled tasks with the exception of the redirect.
Get rid of the <%%>s and the redirect Quote:
|
|
#3
|
|||
|
|||
|
You can't use asp objects like server.createobject and response.redirect from vbs scripts that are not running through IIS as an asp page.
__________________
====== Doug G ====== I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain |
|
#4
|
|||
|
|||
|
Try this to run ASP as scheduled job
Check the below link. I haven't tried it yet, but the logic should work
www[dot]eggheadcafe[dot]com/PrintSearchContent[dot]asp?LINKID=139 Regards Yogi |
|
#5
|
||||
|
||||
|
Quote:
Anything that comes from the Server object needs to be changed to the Wscript object. You can change this to Wscript.CreateObject or simply just drop it altogether to CreateObject. Any Response.Write should be changed to something like Wscript.Echo. Response.Redirect obviously doesn't convert because you can't navigate pages in a VBS. The additional code block should be included in the current script.
__________________
Click the image if at any point you don't like my decision.Scripting problems? Windows questions? Ask the Windows Guru! |
|
#6
|
|||
|
|||
|
Coupla thoughts
1. How long does the script take to run? 2. Is it more than once a day or time critical? If the answers are "no time at all/not long " and "No" have you thought of a short script in the header of one of your pages (index maybe?) that checks a db for a date field and if date < or = today then runs your .asp and updates the date field to next_date_to_run_script. The first user to access the page on, or after, the date specified will initiate the script in your asp. If you are worried about the time to run the script you can cover/fudge this by including Response.write "Please wait loading ..." However, i have no idea of the impact of the response.redirect command in your asp but this might give you and idea or two. "Quick and dirty" maybe but it works and follows the KISS principle HTH Cheers |
![]() |
| Viewing: ASP Free Forums > System Administration > Windows Scripting > Run ASP script as a scheduled job? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|
|