Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

schedule asp script

Posted on 2009-04-06
4
293 Views
Last Modified: 2012-05-06
Hello Experts,

I have an ASP script running on a web server that I would like to schedule to run at a particular time each day at 14:00 hrs.

This ASP script is currently kicked off manually through a web page submission on the server, but I need to be able to schedule the submission time for this script to operate each day automatically.

I have tried with the following code but this does not seems to be working...

test.asp
=======

<%
dim fs,fname
set fs=Server.CreateObject("Scripting.FileSystemObject")
set fname=fs.CreateTextFile("c:\temp\test.txt",true)
fname.WriteLine("Hello World!")
fname.Close
set fname=nothing
set fs=nothing
%>


scheduler
========

Run As
=======
C:\Windows\System32\cmd.exe /c "C:\WINDOWS\system32\wscript.exe C:\VBScripts\RunIE.vbs http://www.website.co.uk/FS_USER/GIFTPACK/test.asp"

Start In
========
C:\PROGRA~1\INTERN~1


RunIE.vbs
=========

URL = WScript.Arguments.Item(0)
Set objIExplorer = CreateObject("internetexplorer.application")
objIExplorer.visible = False
objIExplorer.navigate URL

Please advise

Thanks
S
0
Comment
Question by:newbie27
  • 2
  • 2
4 Comments
 
LVL 25

Expert Comment

by:SStory
ID: 24078661
Some host providers have an option for scheduling a page to be called at a given interval. One is DiscountASP.net.

This could be an option.  I can't ever imagine wanting to run IE on the Server end.
Here is a good article on it.  Method 3 seems the best:
http://www.asp101.com/articles/john/schedule/default.asp
0
 
LVL 8

Author Comment

by:newbie27
ID: 24084979
Hello SStory

Hello,

Thanks for the link. I have followed Method 3 as per your suggestion, However, it still not executing the asp page i wanted
to run as a test. I dont know If I am doing anything wrong here.

All I have done is created a .vbs file and tried to call above test.asp page but its not working...

I have tried both from the command prompt and from the scheduler .... please can you advise?

Thanks

RunBrowser.vbs
==============
 
Option Explicit
On Error Resume Next
 
' Declare our vars
Dim objWinHttp, strURL
 
' Request URL from 1st Command Line Argument.  This is
' a nice option so you can use the same file to
' schedule any number of differnet scripts just by
' changing the command line parameter.
strURL = WScript.Arguments(0)
 
' Could also hard code if you want:
'strURL = "http://localhost/ScheduleMe.asp"
 
' For more WinHTTP v5.0 info, including where to get
' the component, see our HTTP sample:
' http://www.asp101.com/samples/winhttp5.asp
Set objWinHttp = CreateObject("WinHttp.WinHttpRequest.5")
objWinHttp.Open "GET", strURL
objWinHttp.Send
 
' Get the Status and compare it to the expected 200
' which is the code for a successful HTTP request:
' http://www.asp101.com/resources/httpcodes.asp
If objWinHttp.Status <> 200 Then
	' If it's not 200 we throw an error... we'll
	' check for it and others later.
	Err.Raise 1, "HttpRequester", "Invalid HTTP Response Code"
End If
 
' Since in this example I could really care less about
' what's returned, I never even check it, but in
' general checking for some expected text or some sort
' of status result from the ASP script would be a good
' idea.  Use objWinHttp.ResponseText
 
Set objWinHttp = Nothing
 
If Err.Number <> 0 Then
	' Something has gone wrong... do whatever is
	' appropriate for your given situation... I'm
	' emailing someone:
	Dim objMessage
	Set objMessage = Server.CreateObject("CDO.Message")
	objMessage.To       = "admin@framedshare.co.uk"
	objMessage.From     = "admin@framedshare.co.uk"
	objMessage.Subject  = "An Error Has Occurred in a " _
		& "Scheduled Task"
	objMessage.TextBody = "Error #: " & Err.Number & vbCrLf _
		& "From: " & Err.Source & vbCrLf _
		& "Desc: " & Err.Description & vbCrLf _
		& "Time: " & Now()
							
	objMessage.Send
	Set objMessage = Nothing
End If

Open in new window

0
 
LVL 25

Accepted Solution

by:
SStory earned 500 total points
ID: 24086815
How are you executing it?  Do you have the error messages enabled?  If so what error code are you getting?

I think by GETting the page, the server should run the scripts on it. That being the case there is also the GNU wget command.

Install wget,

then if you want to make it easier to call:
either put the directory in your path or put a .BAT file in a  utils directory that is in your path and call it wget.bat
Put the code below inside of that.
=====
@echo off
"C:\Program Files\GnuWin32\bin\wget.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9
=====

Either way, be sure that the argument--the URL-- is surrounded by double quotes " "

The link to WGET is:
http://www.gnu.org/software/wget/

It is great for many things... say there is a file on a webpage that causes a player to come up due to the MIME types and you just actually wanted the file. wget could get it for you.
0
 
LVL 8

Author Comment

by:newbie27
ID: 24086993
thanks this seems to have worked...

created a .bat file and called the page to execute by

wget url

i have noticed that after executing the page it was downloading it ...

so i have added del url command in the batch file...

this should be ok i guess?

thanks for the help
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question