Quantcast
Channel: Task Scheduler Managed Wrapper
Viewing all articles
Browse latest Browse all 2206

New Post: Windows XP SP3 System Account.

$
0
0
Hi,

I have a problem registering a task in windows XP SP3 and run it under system account.
The task is created but when i hit run nothing happens: no entry in log file and "LastRunTime" is Never.


Can anybody tell me what are the correct commands in order to achieve this ?
                using (TaskService ts = new TaskService())
                {
                    isVersionOne = ts.HighestSupportedVersion < new Version(1, 2);

                    TaskDefinition td = ts.NewTask();
                    td.RegistrationInfo.Description = "Task";
                    td.RegistrationInfo.Author = "Me";
                    td.Principal.UserId = @"System";
                    td.Principal.LogonType = TaskLogonType.ServiceAccount;
                    td.Settings.RunOnlyIfLoggedOn = true;
                    td.Triggers.Add(new DailyTrigger
                    {
                        StartBoundary = DateTime.Now,
                        DaysInterval = 2
                    });

                    td.Actions.Add(new ExecAction("\"" + @"C:\ConsoleApplication.exe" + "\""));
                    var task = ts.RootFolder.RegisterTaskDefinition("Test Task", td, TaskCreation.Create, null, null, TaskLogonType.ServiceAccount, null);
                }

Thank you !

Viewing all articles
Browse latest Browse all 2206

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>