I have a problem with defining the local machine when trying to pull a list of Scheduled Tasks.
“localhost” doesn’t seem to work, how could I define the current / local computer
private void testing_Click(object sender, EventArgs e)
{
// Get a ScheduledTasks object for the computer named "DALLAS"
ScheduledTasks st = new ScheduledTasks(@"localhost");
// Get an array of all the task names
string[] taskNames = st.GetTaskNames();
// Open each task, write a descriptive string to the console
foreach (string name in taskNames)
{
Task t = st.OpenTask(name);
MessageBox.Show(" " + t.ToString());
t.Close();
}
// Dispose the ScheduledTasks object to release COM resources.
st.Dispose();
}
From the documentation computer name needs to be a UNC name:
ScheduledTasks Constructor (String)
Therefore, the following should work: