Vous pouvez lancer un processus d'appel SCHTASKS.exe
Voici un code que je faisais juste que:
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = "SCHTASKS.exe";
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
p.StartInfo.Arguments = String.Format(
"/Change /S {0} /TN {1} /RU {2}\\{3} /RP {4}",
MachineName,
ScheduledTaskName,
activeDirectoryDomainName,
userName,
password
);
p.Start();
// Read the error stream first and then wait.
string error = p.StandardError.ReadToEnd();
p.WaitForExit();
if (!String.IsNullOrWhiteSpace(error))
{
throw new Exception(error);
}
Yup. Je n'ai pas encore eu l'occasion d'essayer les solutions, mais une fois que je le ferai, j'accepterai certainement une réponse – xbonez