Thanks dahall for your response. Appreciate it.
After posting this doubt I was able to figure out a solution. I am pasting the same line of code I am using here so that anyone can use if required.
1) I run my application (the scheduler which schedule job using library ) under IIS. It is basically a a web service which can be used to schedule task in windows.
2) IIS app pool runs as NETWORK SERVICE
3) Task run even if no one is logged in into the machine
4) Web service is running on the same machine where task are created
5) Task uses only local resources when they run
All the above features are working and tested. It is on production.
After posting this doubt I was able to figure out a solution. I am pasting the same line of code I am using here so that anyone can use if required.
td.Principal.Id = "any string";
td.Principal.GroupId = "NETWORK SERVICE";
td.Principal.RunLevel = TaskRunLevel.LUA;
td.Principal.LogonType = TaskLogonType.S4U;
Following things are applicable in my case1) I run my application (the scheduler which schedule job using library ) under IIS. It is basically a a web service which can be used to schedule task in windows.
2) IIS app pool runs as NETWORK SERVICE
3) Task run even if no one is logged in into the machine
4) Web service is running on the same machine where task are created
5) Task uses only local resources when they run
All the above features are working and tested. It is on production.