Windows Scripting
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsSystem AdministrationWindows Scripting

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
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  
Old January 15th, 2008, 02:57 PM
bobshishka bobshishka is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 51 bobshishka User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 15 h 16 m 12 sec
Reputation Power: 3
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 %>

Reply With Quote
  #2  
Old January 16th, 2008, 03:48 PM
blicci's Avatar
blicci blicci is offline
Contributing User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Location: Philly
Posts: 335 blicci User rank is Sergeant Major (2000 - 5000 Reputation Level)blicci User rank is Sergeant Major (2000 - 5000 Reputation Level)blicci User rank is Sergeant Major (2000 - 5000 Reputation Level)blicci User rank is Sergeant Major (2000 - 5000 Reputation Level)blicci User rank is Sergeant Major (2000 - 5000 Reputation Level)blicci User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 17 h 23 m 40 sec
Reputation Power: 52
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:
Originally Posted by bobshishka
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 %>

Reply With Quote
  #3  
Old January 16th, 2008, 08:37 PM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 15 h 34 m 6 sec
Reputation Power: 180
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

Reply With Quote
  #4  
Old February 16th, 2008, 07:32 AM
ryogi ryogi is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 1 ryogi User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 sec
Reputation Power: 0
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

Reply With Quote
  #5  
Old February 20th, 2008, 12:24 AM
Nilpo's Avatar
Nilpo Nilpo is offline
ASP Free Novice (500 - 999 posts)
 
Join Date: Jun 2006
Location: Salem, OH
Posts: 675 Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)Nilpo User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1Folding Points: 156663 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Days 18 h 35 m 6 sec
Reputation Power: 308
Send a message via ICQ to Nilpo Send a message via AIM to Nilpo Send a message via MSN to Nilpo Send a message via Yahoo to Nilpo Send a message via Google Talk to Nilpo Send a message via Skype to Nilpo
MySpace
Quote:
Originally Posted by Doug G
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.
Correct.

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!


Reply With Quote
  #6  
Old March 18th, 2008, 02:52 AM
bernieboy31 bernieboy31 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2007
Location: London, UK
Posts: 16 bernieboy31 User rank is Private First Class (20 - 50 Reputation Level)bernieboy31 User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 10 h 44 m 5 sec
Reputation Power: 0
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

Reply With Quote
Reply

Viewing: ASP Free ForumsSystem AdministrationWindows Scripting > Run ASP script as a scheduled job?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway