Object reference not set to an instance of an object
This error happens when you try to use a property or call a method of an object that is null. More details:
here[
^]
Based on what you report,
jobstatus = tsksch.Tasks(jobname).Status.ToString()
this simply means either of the following:
1.
tsksch
was
null
- failed to find the scheduler to create object
2.
tsksch.Tasks(jobname)
was
null
- failed to find any task in scheduler by name mentioned in jobname
find it, and then handle the core reason on why it happened on your server. See if correctly scheduled or not? Scheduler accessible? Some permissions issue?