Hi Jens,
Sorry for reopening this thread all over again.
I read your article in detail and followed it but
ran into a problem. I am sure you have a fix for it. So, here goes...
I took your code and put it in a batch file for
testing. Here is what batch file looked like:
code:
JT.EXE /CTJ StartDate=TODAY StartTime=NOW
HasEndDate=0 KillAtDuration=0 Disabled=0
Type=ONCE /SC domain\domadmin password /SJ
ApplicationName="test.exe" Parameters=""
WorkingDirectory="C:\WINNT" Comment="Test Script"
Creator="Administrator" Priority=Normal
MaxRunTime=21600000 DontStartIfOnBatteries=0
KillIfGoingOnBatteries=0 RunOnlyIfLoggedOn=0
SystemRequired=0 DeleteWhenDone=1 Suspend=0
StartOnlyIfIdle=0 KillOnIdleEnd=0
RestartOnIdleResume=0 Hidden=0 TaskFlags=0 /SAJ
Test.job /SAC Test.job /RJ
The credentials it is using in the JT.EXE command
line are of a Domain Admin account and I am
scheduling the job on the local computer with a
non-privileged account (that is how I am logged
on). It works great the first time and the job
executes and gets deleted when finished. The
problem is that when execute the same batch file
a second time, I get the following error:
code:
[TRACE] Created trigger 0
[TRACE] Setting account information
[TRACE] Setting job's properties
[TRACE] Adding job 'Test.job'
[FAIL ] ITaskScheduler::AddWorkItemn hr=0x80070005
Looking at the c:\winnt\SchedLgU.txt reveals the following problen:
code:
"Test.job" (test.exe) 11/8/2002 10:27:00 PM ** ERROR **
The attempt to retrieve account information for the specified task failed;
therefore, the task did not run. Either an error
occurred, or no account information existed for the task.
The specific error is:
0x8004130f: No account information could
be found in the Task Scheduler security database
for the task indicated.
Doing some research, found the following KB article at Microsoft:
Scheduled Task Does Not Run...
It sounds like even though the job is getting
deleted, the security descriptor is still being
kept in the database against that job name and
deleting ity is breaking it and can never be used
again.
So here I am seeking the advice of the masters of
this trade. Please help!
Thanks!
Anupam Agarwal
[ 09. November 2002, 05:56: Message edited by: Anupam Agarwal ]