E
e.e@e
Hi all,
I have this code to delete scheduled jobs by specifying job id but I
need to delete all current scheduled jobs on the machine.
Do I need to discover all job ids and then feed to this code or is
there an easier way? thanks
public static uint Delete(uint JobID)
{
ManagementObject mo;
ManagementPath path = ManagementPath.DefaultPath;
path.RelativePath = "Win32_ScheduledJob.JobId=" + "\"" + JobID "\"";
mo = new ManagementObject(path);
ManagementBaseObject inParams = null;
// use late binding to invoke "Delete" method on "Win32_ScheduledJob"
WMI class
ManagementBaseObject outParams = mo.InvokeMethod("Delete",inParams,
null);
return ((uint)(outParams.Properties["ReturnValue"].Value));
}
I have this code to delete scheduled jobs by specifying job id but I
need to delete all current scheduled jobs on the machine.
Do I need to discover all job ids and then feed to this code or is
there an easier way? thanks
public static uint Delete(uint JobID)
{
ManagementObject mo;
ManagementPath path = ManagementPath.DefaultPath;
path.RelativePath = "Win32_ScheduledJob.JobId=" + "\"" + JobID "\"";
mo = new ManagementObject(path);
ManagementBaseObject inParams = null;
// use late binding to invoke "Delete" method on "Win32_ScheduledJob"
WMI class
ManagementBaseObject outParams = mo.InvokeMethod("Delete",inParams,
null);
return ((uint)(outParams.Properties["ReturnValue"].Value));
}