2

tengo una duda resulta que estoy haciendo una consola que me crea una tarea programada en windows, al colocarle las credenciales de windows me crea la tarea sin problemas, el problema es que necesito crear esa tarea programada sin las credenciales, algúna idea de cómo hacerlo?

acá el código:

  using (ScheduledTasks Tareas = new ScheduledTasks())
                {

                    TaskScheduler.Task tarea = Tareas.CreateTask("Reprogramando");
                    Tareas.DeleteTask("Reprogramando");

                    tarea.ApplicationName = @"C:\Users\"+userName+"\\Desktop\\Programa.exe";
                    tarea.Comment = "Tarea reprogramada del programa semanal";
                    // Acá deseo que se cree sin la SetAccountInfo 
                    tarea.SetAccountInformation("userName", "Password");
                    // limitar la duración de la tarea programada
                    tarea.MaxRunTime = new TimeSpan(0, 15, 0);
                    tarea.Creator = "Ac";
                    // prioridad de la tarea
                    tarea.Priority = System.Diagnostics.ProcessPriorityClass.Normal;

                    tarea.Triggers.Add(new RunOnceTrigger(task.AddHours(1)));
                    tarea.Save();
                }
2
  • donde ingresas las credenciales de windows ? el 22 nov. 2018 a las 18:43
  • en esta línea estimado tarea.SetAccountInformation("userName", "Password"); el 22 nov. 2018 a las 18:50

1 respuesta 1

1

Analicemos la documentacion de la libreria

A New Task Scheduler Class Library for .NET

Tienes justamente la pregunta que hace referencia a como asignar las credenciales.

Must I have an account and password for a task?

A scheduled task must be given a specific account in which to run or it may be set to run in the local system account. The local system account is a pseudo-account used by many of the standard services. It has broad access to the local system, but it cannot always interact with the user directly and it has no network privileges. To set a task to run in the local system account, the client must be already running in that account or in an administrator account.

If the task will need to interact with the user, you need to set a specific user account and the task will only interact with that user. If your client runs in different accounts depending on who is using it, you can have it schedule tasks without actually knowing the user's password. To this, you set a specific task flag, RunOnlyIfLoggedOn and give the user name and a null password.

El indicar o no el usuario y password tiene que ver si la aplicacion que vas a ejecutar tendra interaccion con el usuaurio.

Podrias indicar la propiedad RunOnlyIfLoggedOn entonces definir el nombre de un usuario pero con el password en null

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.