Question

I have created a couple of batch jobs and associated tasks to them, they run fine. But one problem is that they run with the account I have used to create the jobs in the first place. I would like to be a system account instead of my personal account (which could be deactivated if I ever leave this place)

I see nowhere to change this. Do I have to change it via an SQL update statement ?

Thanks.

Was it helpful?

Solution

You can log-in as whatever service user you want and setup the batch jobs, or you can use runas(...) to do it from code easily (http://msdn.microsoft.com/en-us/library/aa893873.aspx):

server static public void Main(Args _args)
{
    RunAsPermission perm;
    UserId          runAsUser;
    SysUserInfo     userInfo;

    userInfo = SysUserInfo::find();
    runAsUser = userInfo.Id;
    perm = new RunAsPermission(runAsUser);
    perm.assert();

    runAs(runAsUser, classnum(EventJobDueDate), "runDueDateEventsForUser");

    CodeAccessPermission::revertAssert();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top