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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Manipulating/creating tasks in Task Scheduler 1

Status
Not open for further replies.

mousseman

MIS
Aug 5, 2002
17
0
0
CH
Hi!

Been programming VBScript, and I need something with which I can create an entry or maybe even manipulate it. MicroSoft has a taskscheduler.exe archive, but I have not been able to make it schedule tasks when I want it to (it always schedules tasks at 12:00 AM, with a start date of 31/12/1899). Maybe the stuff from Microsoft is just way broken, or at least badly documented and the default entry in the tasks.xml has the wrong parameters.

Does anybody have a decent documentation of the MS SchedulingAgent.DLL that one can download at



or a COM+ object that allows me to access the scheduler from vbscript?

CU

mousseman
 
Hi !
I had the same problem and followed your link, download the exe from Microsoft and work on it.
[idea]Just switch the date and time parameters to make it run :
Here is an example of what it could be :

Dim vSched
Dim vdate, vtime
vdate = "MM/DD/YYYY"
vtime = "HH:MN xM" 'ie AM or PM
Set vSched = WScript.CreateObject("SchedulingAgent.NTScheduler")
vSched.ISchedulingAgent_ScheduleTask "TaskName", "command", "parameters","USERNAME","PASSWORD",vdate,vtime

Notes :
1) This piece of code is supposed to run in an environment where the SchedulingAgent.dll is registered
2) Date and Time format must be English format
3) I didn't yet found how to run my command repeateadly !!

The only interest I found in the SchedulingAgent.NTScheduler object provided by the dll is the ability to make a scheduled task run in a specific user security environment. Be aware of the fact that the TaskScheduler only runs as LocalSystem account, avoiding access to other computers.
 
Hi,

Wish I'd seen this a week ago, would have saved me the hassle of finding this out for myself!!

Anyway, have you yet found a way to run a command repeatedly? I need to schedule a task and run it every 15 minutes but I can't use the AT command as it needs to run with a domain admin account. The above is the closest I've found to achieving my needs!

Cheers, Antony
 
hi

I am trying to schedule the task to repeat every minute and it is very much needed. Can you help me out if you have found the way to do it.

I have followed the same steps as given in this.

Thanks
sujatha
 
if you use Task Scheduler manually you can add other information like the Start In directory, and to have the script repeat every 5 minutes, etc. Can these options be set through this script?
 
mousseman,

A call to this sub will resubmit the script.

Call ReSubmit(15,n) ' Resubmits this script in 15t minutes.

' ****************
Sub ReSubmit(intrvl_tmp_val, intrvl_tmp_type)
' ****************
' Now resubmit the job one hour from now
' Set the next execution time. h = hour, n = minutes, s = seconds, d = day
strdate = date
strtime = time

nextexec = DateAdd(intrvl_tmp_type, intrvl_tmp_val, strDate & " " & strtime)
darray = split(nextExec, " ")
nexttime = trim( darray(1) ) & trim( darray(2) ) ' Morning or afternoon
'
' If today's execution time is different than next execution time, change the command string
' This allows an execution time to switch to another day and time
If Weekday(strDate) = Weekday(nextExec) then
strTmp = ""
Else
strTmp = " /next:" & WeekDayName( Weekday(nextExec) )
End If

x = WshShell.run("cmd /c at " & nexttime & strTmp & " " & Wscript.ScriptFullName)

End Sub


fengshui_1998

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top