Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set application var from script 1

Status
Not open for further replies.

CFDude

Programmer
Nov 7, 2001
316
US
Hello!

I have an array set as an application variable (the array is used for a drop down list on a page) -- currently I have the variable set on the first request of the page for the day. What I would like to do is schedule a script to be run at a pre-defined time that would set this application variable. I was thinking of using a vbs script, but I am not sure if I can set an application variable this way.

Any help would be appreciated.

Tim P.
 
The variable would only be good for the lifetime of the application that starts the process. If you have a script run at a specific time to set a variable, then it will be set for that thread.

You might have the best solution already. _______________________________________________
OutsideIntranets.com
Stop wasting time, get to work
 
How is the array populated? From a database, text file, user input, etc?

Thanks,

Gabe
 
To give you some more info: The array is populated from a database -- the query could take a little while to run, so I force that on the first user of the application of the day
(I set another application var for the date that it was last run, and if it was run today, then use the array held in memory, otherwise, run the query again and copy it to the application scope and set the date)

Not to bore you, but before all that, we repopulate the report database every morning starting at midnight and ends by 4:30. If I run the query to grab the information for the array prior to 4:30, then all the data may not be there to populate the query. Also, I hate to subject the first user of the app for the day to wait for the query to end. This usually happens to be the CFO, who gets in at 4 every morning.

Anyways, now that I think of it, I may just check the time too, and if it hasn't been set AFTER 4:30 then reset it. Unless anyone else has a better way.

Thanks in advance for your time!
 
You could always set a shortcut to the page on the desktop than create a scheduled task to run that shortcut at a certain time every morning, thus forcing that page to be the unlucky first user.
-Tarwn --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
For my next trick I will pull a hat out of a rabbit (if you think thats bad you should see how the pigeon feels...) :p
 
Tarwn, could you explain your solution a little more for me. It sounds interesting. What I can't figure out is if no one is logged into the server, there isn't a desktop.

This will take a little more programming and I don't know what your comfort level is but I would try to tie the populating of the report database with the update of the web application array.

I would create an asp page that populates the array when the page is called. I would put this in a subfolder of the web application and restrict it so that no one could access it except admins of the application and the users a scheduled task runs under.

I would write a VB Exe that would use the Internet Explorer ActiveX control. This executable would navigate the IE control to the admin asp page mentioned above. This would kick off repopulating the array. You could schedule a task on the web server (I’m assuming you are running WinNT or 2000) to run the executable everyday at a specific time.

Another option that we have used is have SQL Server run the executable. If you are using SQL Server you can create a series of events. First you would populate the report database then you would run the VB.exe you created. SQL Server has the ability to run executables AND interact with COM objects.

Or you could set your alarm clock for 4:30 am every morning and getup and hit the admin page yourself.

I hope this gives you some ideas.

Thanks,

Gabe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top