C# Why can I not programmatically kill a console program started in Task Scheduler? -
i have console program run daily batch. have ui can use alter parameters in db console program uses.
i thought great able stop , start program ui , can that.
however, have console program set start before work day using task scheduler in case machine should rebooted - @ least know program running when day starts.
however, cannot kill when has been started task scheduler. "access denied".
why? , how can solve this?
try using following method:
private void killprocessbyprocessname(string strprocessname) { foreach (process p in system.diagnostics.process.getprocessesbyname(strprocessname)) p.kill(); }
e.g:
private void btnprocesskiller_click(object sender, eventargs e) { killprocessbyprocessname("winword"); }
Comments
Post a Comment