This project has moved and is read-only. For the latest updates, please go here.

TaskLogonType.Group Error on Windows 7 professional

Topics: Errors
May 31 at 3:51 AM
I need to create a task that will from time to time on different user admin accounts .
So, when I try using the "Principal.LogonType = TaskLogonType.Group;" on my computer with Windows 8, it works fine, but when I use this on a Windows 7 professional, it gives an error on the "LogonType".

I just get a code from you to test this.
                TaskService ts = new TaskService();
                TaskDefinition td = ts.NewTask();
                td.RegistrationInfo.Description = "Run  teste ";
                td.Settings.DisallowStartIfOnBatteries = false;
                td.Settings.ExecutionTimeLimit = TimeSpan.Zero;
                td.Principal.GroupId = "BUILTIN\\Administrators";
                td.Principal.LogonType = TaskLogonType.Group;
                td.Triggers.Add(new LogonTrigger());
                td.Actions.Add(new ExecAction(Application.StartupPath + "\\teste.exe", null, null));
                ts.RootFolder.RegisterTaskDefinition("teste", td);

                MessageBox.Show("Test Ok");
            catch (Exception ex)
                MessageBox.Show("ex: " + ex.ToString());
If I change the "TaskLogonType.Group;" to another type, it doesn't give any error, but it doesn't work, because I need to run as Administrators.

The error message is:
COMException (0x80070534):(49,8):LogonType : in RegisterTaskDefinition in C:\Users\dahall\Documentos\VisualStudio2010\Projects\TaskService\TaskFolder.cs:line448 and line 391
Jun 1 at 7:22 PM
Please try registering the task with the group information and let me know if that fixes the problem:
// Leave all setup code the same
ts.RootFolder.RegisterTaskDefintion("teste", td, TaskCreation.CreateOrUpdate, "BUILTIN\\Administrators", null, TaskLogonType.Group);
Jun 2 at 12:40 AM
I tried that as well. It gives the same error.
Jun 5 at 1:38 PM
So, do you have any other idea? Or perhaps another version for me to try?
Jun 10 at 12:15 AM
I have just tested this while running under an account with Admin rights under Windows 7 (Version 6.1 Build 7601: SP1). I ran your exact code while built against the .NET 2.0 and 4.0 versions of the library. I repeatedly did not see your error.

My guess is that it then has something to do with the user permissions under which you are running while executing on Windows 7. Make sure that account has Admin rights.
Jun 11 at 4:10 AM
Yes, all accounts have Admin rights
Jul 24 at 3:26 PM
Have you run the Troubleshooter on the offending system? That may also give you some insight to problem with permissions.