Print Page | Close Window

How to trigger global.asa automatically

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=9167
Printed Date: 29 March 2026 at 5:15pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: How to trigger global.asa automatically
Posted By: mattsang
Subject: How to trigger global.asa automatically
Date Posted: 22 January 2004 at 11:29pm

Dear Folks,

I would like to write a global asa file (as below) and hope it would initiate itself (without visiting the site) automatically to perform a routine data retrieval from the DB and write it in a mail for making a routine data report via e-mail. As I finished the programming, I tested it and found that it only initiated once and send the e-mail as I wish to my a/c but it did not perform the task routinely..would any expertise here help and modify my coding? Many Many thanks

My main cocern is 1) the script can starts itself in IIS (I have checked the setting in IIS and make it right 2) the script can peform the task routinely

 

My coding

<SCRIPT LANGUAGE=VBScript RUNAT=Server>

Sub Application_OnStart()

Do While not isNull(application("te_todaysDate"))

' CONFIGURATION OPTIONS
' Description: Set the frequency by setting the execution_feq equal to D or H
'
 execution_feq = "H"    ' D = Execute Code Once Daily
             ' H = Execute Code Once Hourly

on error resume next


if UCase(execution_feq) = "H" then

' GET THE TIME IN LONG FORMAT, GRAB THE HOUR
 my_time = FormatDateTime(now(),vblongtime)
 my_time2 = instr(CStr(my_time),":")
 my_time = Left(my_time,my_time2-1)

' IF THE APPLCIATION VARIABLE IS EMPTY INITIALIZE IT AND EXECUTED THE CODE

 if isNull(application("te_todaysDate")) then
  ' execute function/code

  **my e-mail script**
  
  application.lock
  application("te_todaysDate")=my_time
  application.unlock
 end if

' IF THE APPLCIATION VARIABLE IS NOT EQUAL TO TODAYS DATE EXECUTE CODE

 if application("te_todaysDate") <> my_time then
  ' execute function/code

  **my e-mail script**
  
  application.lock
  application("te_todaysDate")=my_time
  application.unlock
 end if

end if

Loop

End Sub

</SCRIPT>




Replies:
Posted By: MadDog
Date Posted: 23 January 2004 at 2:39am
Everytime someone goes to your site the global.asa file is automaticly ran.

-------------
http://www.iportalx.net" rel="nofollow">


Posted By: zaboss
Date Posted: 23 January 2004 at 2:46am
Usualy this is achieved by running a vb script on the server. But you should check with your host if he allows this. Some don't.

-------------
Cristian Banu
http://www.soft4web.ro - Soft 4 web


Posted By: WebWiz-Bruce
Date Posted: 23 January 2004 at 4:56am
You can only have one global.asa file per site and this must go in the root directory of your site.

Each time a user comes to your site the global.asa file is automactically run by the web server.

You do need to check with your host though as not all allow global.asa files and may disable it. Global.asa files won't work on free hosting accounts becuase of the way they are setup.


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: mattsang
Date Posted: 23 January 2004 at 9:13am

Is it possible to make it starts itself (without depending on the visitor surfing) or just initiate the file once, and then to schedule it to run routinely?

I can manage the IIS environment,so the I am not worry about the setting

Anyone have new idea about the coding to achieve my expected results? 

 



Posted By: God_Struth
Date Posted: 23 January 2004 at 10:24am
If your using a windows machine use task scheduler.

-------------
"I'm only trying to help......"


Posted By: mattsang
Date Posted: 23 January 2004 at 10:52am

Originally posted by God_Struth God_Struth wrote:

If your using a windows machine use task scheduler.

I see...you mean the "scheduled tasks" under "system tool" of "Accessories", right?

if so...I really need not write the scripting and save it as global.asa..and just save it as a ordinary ASP and schedule it, right?

 



Posted By: dpyers
Date Posted: 23 January 2004 at 7:49pm

Originally posted by MadDog MadDog wrote:

Everytime someone goes to your site the global.asa file is automaticly ran.

Only when they hit their first asp page. .html pages don't trigger it.



-------------

Lead me not into temptation... I know the short cut, follow me.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net