Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to Register a task with [COMException (0x80041318): (44,4):Task:] #59

Closed
wendy922011 opened this issue Mar 12, 2018 · 4 comments
Closed
Assignees
Labels
Projects

Comments

@wendy922011
Copy link

wendy922011 commented Mar 12, 2018

Hello,
I am trying to register a task through a web app deployed to an IIS server (Windows Server 2012 R2).
The task is to be run one time only. Action is set to be opening the notepad for testing purpose.

using (TaskService ts = new TaskService())
{
TaskDefinition td = ts.NewTask();
td.RegistrationInfo.Description = "Open notepad";
td.Principal.LogonType = TaskLogonType.InteractiveToken;
DateTime time = Convert.ToDateTime(txttime.Text);
DateTime date = Convert.ToDateTime(txtdate.Text);
DateTime send_time = date.Add(time.TimeOfDay);
td.Triggers.Add(new TimeTrigger(send_time));
td.Actions.Add(new ExecAction("notepad.exe", null, null));
//td.Principal.RunLevel = TaskRunLevel.Highest;
TaskFolder tf = ts.GetFolder("\\Microsoft\\Windows\\Notepad");
tf.RegisterTaskDefinition(taskName, td);
}

Use the official one by debugging in localhost is fine but runs into the same error when deployed to server. I have searched over the code and I have no idea what required element or attribute I have missed. Use the wrapper by debugging in localhost also run to an access denied error no matter with or without an admin account.

I am wondering if that is a problem of account permission but adding an account in the Task service config and task registration part only bring more errors like access denied or something like:

Attempted to access an unloaded appdomain. (Exception from HRESULT: 0x80131014)

The tutorial on Task Security provides several approaches but I have tried all possibilities:

  • local computer (no account vs admin account)
  • remote server (NETWORK SERVICE & admin account & no account)
  • interactive token vs account password
  • system account
  • admin right of setting the highest property

I have been struggling in the task registration...
Is it better to get an admin account to get it work ? resulting in a bunch or access error though :(
Thanks in advance for any advice.

Update:
The missing requirement issue was solved by changing the time trigger to
td.Triggers.Add(new TimeTrigger() { StartBoundary = send_time });
locally but the problem is still there to make it work on remote server.
Thanks.

@dahall dahall self-assigned this Mar 15, 2018
@dahall dahall added the bug label Mar 15, 2018
@dahall
Copy link
Owner

dahall commented Apr 5, 2018

Are you impersonating the user in your IIS session? If not, doing so will allow TaskService to be creating using the user credentials instead of IUSER credentials (which are usually restricted).

@dahall
Copy link
Owner

dahall commented Nov 28, 2018

Any update? Can this be closed?

@dahall dahall closed this as completed Dec 1, 2018
@vyasramachandra
Copy link

@dahall Can you explain how impersonating the user in IIS session can be done. Is there any code sample?

I have been facing the above problem even after using multiple ways

@dahall
Copy link
Owner

dahall commented Apr 9, 2021

Please see Wiki

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Library
  
Awaiting triage
Development

No branches or pull requests

3 participants