This project has moved. For the latest updates, please go here.

Help Creating a difficult, maybe impossible, one time task

Topics: Setup
Mar 5 at 12:38 AM
I'm trying to use your plug to create a one-time task that will delete a folder owned by the user running this program when the PC boots before it logs in.

This means the task has to run before login at the windows authentication screen or sooner, with permissions from the AD user that created the task (which I believe is possible because it should gather that uses information before the reboot occurs.)

any help would be appreciated as I've been unable to get anything to work that wasn't repeating task or set with some type of time to run.
Mar 7 at 3:14 PM
Boot triggers require that the task is registered by a member of the Administrators group and have the user's password.

I haven't tested the following, but try this:
      // Create a new task definition for the local machine and assign properties
      var td = TaskService.Instance.NewTask();
      td.RegistrationInfo.Description = "Removes folder on next boot.";

      // Add a boot trigger
      td.Triggers.Add(new BootTrigger());

      // Create an action that will remove a folder (this will be whatever you're using)
      td.Actions.Add("RemFldr.exe", @"C:\users\thisuser\userFldr");

      // Register the task in the root folder of the local machine
      TaskService.Instance.RootFolder.RegisterTaskDefinition("Remove User Folder", td, 
         TaskCreation.CreateOrUpdate, "userDomain\\userName", "userPassword",