ASP VBScript - Running from a Windows Scheduled Task
Warnings
- Looks like memory is not released.
For your own testing look at:
Process name: dllhost.exe
User: IWAM_<machinename>
- Looks like at some point the ASP page will no longer run. To prove
that I had a batch file that logged to a log file when it was run which
launched an ASP web page that logged to a separate log file. I
scheduled a task to run the batch file every 5 min for 1 hour. The ASP
logged for only 30 min and the batch file logged for the full 1 hour.
- When launching a browser from a batch file via a Windows Scheduled Task
the browser will never unload so you must tell the Scheduled Task to stop
the task prior to restarting the task.
Ex: So if running every 5 min have the task stopped after 4 min etc...
Concept:
- Create an ASP web page that will complete your task.
- Create a batch file that will launch IE and then run an ASP web page.
- Run the batch file from a Windows Scheduled Task
Example ASP page:
- If you have downloaded the zip file of all ASP examples see:
MyTextFileA.asp
MyTextFileA_info_localfileaccess.htm
MyTextFileA_batchfile_run_asp_via_ie.bat
Example Batch file:
- Filename: MyTextFileA_batchfile_run_asp_via_ie.bat
- Content to batch file:
"C:\Program Files\Internet Explorer\IExplore.exe" http://localhost/myaspexamples/MyTextFileA.asp?closebrowser=yes
Steps to Schedule a Windows Task (that runs every 5 min).
- Initial steps to create the Scheduled Task.
- From the Control Panel select "Schedule Task", then "Add Schedule Task
Click the Browse button and locate the batch file.
click Next
Perform this task: Daily
click Next
Start Time: A future time.
Start Date: Today
click Next
Enter User Name: <machine name>\administrator
Enter Passwords
click Next
Select box: Open advanced properties for this task when I click Finish
click Finish
- Task Tab:
UnSelect - Run only if logged in.
Select - Enabled (scheduled task run at specified time)
- Schedule Tab:
Schedule Task: Daily
Start Time: A future time.
Schedule Task Daily: Every 1 day
Click Advanced button.
Click Repeat task
Every: 5 min
Select Duration - 24 hours, 0 min
Select: If the task is still running, stop it at this time.
- Setting Tab:
Section (Scheduled Task Completed) - Leave the defaults
* UnSelect " Delete the task if it is not scheduled to run again".
* Select "Stop the task if it runs for: 0 Hours, 4 min
(VERY IMPORTANT or the task will never complete!)
Section (Idle Time) - Leave the defaults
Section (Power Management)
Select - Don't start the task if the computer is running on batteries.
Select - Stop the task if battery mode begins.
Select - Wake the computer to run this task.
- To edit a Scheduled Task.
- From the Control Panel select "Schedule Task". (also right click, then
Explore)
Error: If running scheduled task with a User logon ID that you logon to the
OS with.
Error window title: SysFader: iexplore.exe - Application Error
Error box:
The instruction at 0x0138ac36 referenced memory at "0x00000000". The
memory could not be "read".
For XP Professional my Fix:
Schedule the task to run under "administrator".
Information in the Event Viewer (Application):
Windows saved user THOMASMA9300\<user_logonid> registry while an application or
service was still using the registry during log off. The memory used by the
user's registry has not been freed. The registry will be unloaded when it is no
longer in use.
This is often caused by services running as a user account, try configuring
the services to run in either the LocalService or NetworkService account.
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.