Start A Scheduled Task From ASP Server

C

Colin Steadman

We have a number of scheduled tasks on our IIS server that run daily at some point during the early morning. These tasks run as a specific user that has the correct permissions to perform whatever task (processing SQL so I'm told)

I have been asked if I can setup a page within ASP that a user could logon to with their own credentials (this I can do).

And once logged on be presented with a list of scheduled tasks which they can then restart by clicking a button. The idea is to give them the abiltity to manually run a job, but within giving them the password to the admin account that the sceduled task uses

Does anyone have any thoughts on how this might be done? Would it be as simple as shelling out to the Scheduled Task shortcut and running it

TIA

Coli
 
B

Bob Barrows

Colin said:
We have a number of scheduled tasks on our IIS server that run daily
at some point during the early morning. These tasks run as a
specific user that has the correct permissions to perform whatever
task (processing SQL so I'm told).

I have been asked if I can setup a page within ASP that a user could
logon to with their own credentials (this I can do).

And once logged on be presented with a list of scheduled tasks which
they can then restart by clicking a button. The idea is to give them
the abiltity to manually run a job, but within giving them the
password to the admin account that the sceduled task uses.

Does anyone have any thoughts on how this might be done? Would it be
as simple as shelling out to the Scheduled Task shortcut and running
it?

TIA,

Colin

Are you talking about SQL Agent scheduled tasks (jobs)? Or batch jobs
scheduled using the AT command?

Bob Barrows
 
T

Tom Kaminski [MVP]

Colin Steadman said:
----- Bob Barrows wrote: -----


Are you talking about SQL Agent scheduled tasks (jobs)? Or batch jobs
scheduled using the AT command?

I've just spoken to the customer and asked this question.

The story has changed somewhat. He now says that the job has not yet been
setup, and that he's expecting me to do this bit as well (in whatever way I
feel appropriate). A VBScript would be perfect I think. Can I start a
VBScript and have it run in the background with the credentials of a user of
my choice?

Try something like this: ( I don't remember where I got this from)

Dim oScheduler
Dim objTask
Dim objTrigger
Set oScheduler = CreateObject("Scheduler.SchedulingAgent.1")
Dim TaskName

Set objTask = oScheduler.Tasks.Add("CheckRegistrationReminder")
TaskName = "C:\WINNT\system32\wscript.exe """ & "C:\Program
Files\NellieAdmin\" & "CheckRegistrationReminder.vbs """
objTask.ApplicationName = TaskName
objTask.Comment = "blah blah some comment"
objTask.Creator = "Script File"
objTask.WorkingDirectory = "C:\WINNT\system32"
 
C

Colin Steadman

----- Tom Kaminski [MVP] wrote: -----

Colin Steadman said:
scheduled using the AT command?
setup, and that he's expecting me to do this bit as well (in whatever way I
feel appropriate). A VBScript would be perfect I think. Can I start a
VBScript and have it run in the background with the credentials of a user of
my choice?

Try something like this: ( I don't remember where I got this from)

Dim oScheduler
Dim objTask
Dim objTrigger
Set oScheduler = CreateObject("Scheduler.SchedulingAgent.1")
Dim TaskName

Set objTask = oScheduler.Tasks.Add("CheckRegistrationReminder")
TaskName = "C:\WINNT\system32\wscript.exe """ & "C:\Program
Files\NellieAdmin\" & "CheckRegistrationReminder.vbs """
objTask.ApplicationName = TaskName
objTask.Comment = "blah blah some comment"
objTask.Creator = "Script File"
objTask.WorkingDirectory = "C:\WINNT\system32"

--
Tom Kaminski IIS MVP


Thanks Tom,

Slight problem with it though. Apparently it needs the task scheduler dll which is only available on Microsoft Site Server 3.0 according to this post:

http://groups.google.com/[email protected]

Otherwise you get this error:

Microsoft VBScript runtime error '800a01ad'

ActiveX component can't create object: 'Scheduler.SchedulingAgent.1'

/ColinsDevArea/tasks.asp, line 46


Any other ideas?

TIA,

Colin
 
T

Tom Kaminski [MVP]

Colin Steadman said:
----- Tom Kaminski [MVP] wrote: -----

Try something like this: ( I don't remember where I got this from)

Dim oScheduler
Dim objTask
Dim objTrigger
Set oScheduler = CreateObject("Scheduler.SchedulingAgent.1")
Dim TaskName

Slight problem with it though. Apparently it needs the task scheduler dll
which is only available on Microsoft Site Server 3.0 according to this post:
http://groups.google.com/[email protected]

Otherwise you get this error:

Microsoft VBScript runtime error '800a01ad'

ActiveX component can't create object: 'Scheduler.SchedulingAgent.1'

/ColinsDevArea/tasks.asp, line 46


Any other ideas?

I think WMI might be the way to go, I was able to find this:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_scheduledjob.asp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top