ITaskScheduler and scheduling a task under system account

  • Thread starter Thread starter Senapathy
  • Start date Start date
S

Senapathy

Hello all,

Environment: W2K SP3, VC6

I create a scheduled task in W2K using the ITaskScheduler, ITask interfaces.
1) ITaskScheduler::NewWorkitem
2) ITask::CreateTrigger
3) ITask::SetAccountInformation
4) IPersistFile::Save

The code that I use for setting the account information is the following:
if(strUser.IsEmpty())
{
hr = pTask->SetAccountInformation(L"", NULL);
}
else
{
hr = pTask->SetAccountInformation(strUser, strPwd);
}

- If I pass a non-empty user name password combination to set the account
information, the task runs properly.
- If I pass the the account information as L"" - in order to run under
system account - it creates the task, but the task does not run.

I can see in the scheduled task system log the following error:
" The attempt to log on to the account associated with the task failed,
therefore, the task did not run.
The specific error is:
0x8007054b: The specified domain either does not exist or could not be
contacted.
Verify that the task's Run-as name and password are valid and try again."

Can anyone tell me how to run a task under the system account?

Senapathy
 
Senapathy said:
Hello all,

Environment: W2K SP3, VC6

I create a scheduled task in W2K using the ITaskScheduler, ITask interfaces.
1) ITaskScheduler::NewWorkitem
2) ITask::CreateTrigger
3) ITask::SetAccountInformation
4) IPersistFile::Save

The code that I use for setting the account information is the following:
if(strUser.IsEmpty())
{
hr = pTask->SetAccountInformation(L"", NULL);
}
else
{
hr = pTask->SetAccountInformation(strUser, strPwd);
}

- If I pass a non-empty user name password combination to set the account
information, the task runs properly.
- If I pass the the account information as L"" - in order to run under
system account - it creates the task, but the task does not run.

I can see in the scheduled task system log the following error:
" The attempt to log on to the account associated with the task failed,
therefore, the task did not run.
The specific error is:
0x8007054b: The specified domain either does not exist or could not be
contacted.
Verify that the task's Run-as name and password are valid and try again."

Can anyone tell me how to run a task under the system account?

Senapathy

Use at.exe instead of your script.
 
Hello Pegasus,

I cannot. I need to schedule tasks with a lot of flexibility - for instance
run Every Thu and Fri of the week, run every 2nd, 10th and 15th of a month
etc.
AT.exe does not give these options.

Otherwise I would never have attempted such a complicated method at
all...:-(

Senapathy
 
You can do all of this by using the GUI of the Task
Scheduler, and using a dedicated account for your
tasks. I cannot see any reason to use the System
account.
 
Back
Top