CodePlexProject Hosting for Open Source Software
An unexpected error has occured.
There is an unsaved comment in progress. You will lose your changes if you continue. Are you sure you want to reopen the work item?
Closed
smurfiv wrote Jan 20, 2012 at 7:39 PM
using (TaskService ts = new TaskService()) { // Create a new task // Create a new task definition and assign properties TaskDefinition td = ts.NewTask(); td.Data = "Your data"; td.Principal.UserId = user; td.Principal.LogonType = TaskLogonType.InteractiveToken; td.RegistrationInfo.Author = "Elucidate"; td.RegistrationInfo.Description = "Performs the SnapRAID Sync command after a small delay after logon"; td.RegistrationInfo.Documentation = "http://elucidate.codeplex.com/documentation"; td.Settings.DisallowStartIfOnBatteries = true; td.Settings.Enabled = true; td.Settings.ExecutionTimeLimit = TimeSpan.FromHours(24); td.Settings.Hidden = false; td.Settings.Priority = System.Diagnostics.ProcessPriorityClass.Normal; td.Settings.RunOnlyIfIdle = false; td.Settings.RunOnlyIfNetworkAvailable = false; td.Settings.StopIfGoingOnBatteries = true; Version ver = ts.HighestSupportedVersion; bool newVer = (ver >= new Version(1, 2)); // Create a trigger that fires 15 minutes after the current user logs on and then every 1000 seconds after that LogonTrigger lTrigger = (LogonTrigger)td.Triggers.Add(new LogonTrigger()); if (newVer) { lTrigger.Delay = TimeSpan.FromSeconds(30); lTrigger.UserId = user; } // Create an action which opens a log file in notepad td.Actions.Add(new ExecAction("cmd", @"/k" + FormatSnapRaidCommandArgs("Sync"), null)); // Register the task definition (saves it) in the security context of the interactive user return ts.RootFolder.RegisterTaskDefinition(taskName, td, TaskCreation.CreateOrUpdate, null, null, TaskLogonType.InteractiveToken, null); }
dahall wrote Jan 21, 2012 at 6:42 AM
smurfiv wrote Jan 21, 2012 at 9:13 AM
dahall wrote Jan 21, 2012 at 4:18 PM
smurfiv wrote Jan 22, 2012 at 12:01 PM
smurfiv wrote Jan 22, 2012 at 12:05 PM
dahall wrote Jan 23, 2012 at 4:43 AM
smurfiv wrote Jan 23, 2012 at 4:39 PM
dahall wrote Jan 23, 2012 at 7:51 PM
td.Principal.UserId = user; and change the RegisterTaskDefinition line at the end to: ts.RootFolder.RegisterTaskDefinition(taskName, td);
smurfiv wrote Jan 24, 2012 at 5:51 PM
dahall wrote Jan 25, 2012 at 5:05 PM
smurfiv wrote Jan 25, 2012 at 5:36 PM
smurfiv wrote Jan 26, 2012 at 6:44 PM
dahall wrote Jan 27, 2012 at 6:14 AM
td.Principal.UserId = user; td.Principal.LogonType = TaskLogonType.InteractiveToken;
smurfiv wrote Jan 27, 2012 at 7:57 AM
smurfiv wrote Jan 27, 2012 at 6:26 PM
td.Principal.UserId = user; in the template function and then using the task directly in the Edit dialog causes an exception to be thrown when pressing ok. I can also confirm that the timings (Delay) are the same.
dahall wrote Jan 30, 2012 at 3:27 AM
smurfiv wrote Jan 30, 2012 at 4:15 PM
dahall wrote Jan 30, 2012 at 5:52 PM
Sign in to add a comment
Keyboard shortcuts are available for this page.