Necesito obtener una lista de todas las tareas programadas que se ejecutan en un determinado host en una lista o matriz en C#.Cómo leer la salida estándar de un comando ejecutado a través de Process.Start() como una lista o matriz
La consulta
schtasks /query /S CHESTNUT105B /FO List
devuelve una lista como esta:
HostName: CHESTNUT105B
TaskName: Calculator
Next Run Time: 12:00:00, 10/28/2010
Status: Running
HostName: CHESTNUT105B
TaskName: GoogleUpdateTaskMachineCore
Next Run Time: At logon time
Status:
HostName: CHESTNUT105B
TaskName: GoogleUpdateTaskMachineCore
Next Run Time: 13:02:00, 10/28/2010
tengo el siguiente código para ejecutar el comando que se especifica más arriba:
static void Main(string[] args)
{
Process p = new Process();
p.StartInfo.UseShellExecute = false;
p.StartInfo.FileName = "SCHTASKS.exe";
p.StartInfo.RedirectStandardError = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
string MachineName = "CHESTNUT105b";
string ScheduledTaskName = "Calculator";
string activeDirectoryDomainName = "xxx";
string userName = "xxx";
string password = "xxxxx";
p.StartInfo.Arguments = String.Format("/Query /S {0} /FO LIST", MachineName);
p.Start();
}
¿Cómo puedo leer la lista generada en una lista en C#?
Estoy seguro de que hay una mejor manera de recuperar la lista - a través de las clases WMI, pero no sé lo suficiente de ese espacio de nombres para ofrecer una respuesta. – Oded