I'm trying to use remote task scheduler and make sure the service is running on the remote machine. I use the following. Notice the servicename is Alerter. That works, but when I try Task Scheduler I get an error. I noticed that Task Scheduler is listed as a Local System instead of a Local Service in Services. Any ideas?
ServiceController sc = new ServiceController();
sc.MachineName = "computer name";
sc.ServiceName = "Alerter";
MessageBox.Show(sc.Status.ToString());
if (!sc.CanStop)
sc.Start();
Loading
Guest UserPosted Dec 29, 2010, 1:38 PM
sc GetKeyName "Task Scheduler"
The following output is generated:
[SC] GetServiceKeyName SUCCESS
Name = Schedule
So if you set sc.ServiceName = "Schedule" in your code, it should work.
For Alerter, the display and key names are both "Alerter" which is why your code worked for that service.
JasonPosted Dec 29, 2010, 3:27 PM
Guest UserPosted Dec 29, 2010, 2:18 PM
If you have a minute, could you mark my reply as the accepted answer? I'd appreciate it!
JasonPosted Dec 29, 2010, 2:11 PM
Guest UserPosted Dec 29, 2010, 2:03 PM
Can you ping that server using the same name as your MachineName setting?
JasonPosted Dec 29, 2010, 1:52 PM
JasonPosted Dec 29, 2010, 11:53 AM
Guest UserPosted Dec 29, 2010, 11:43 AM
Try changing the startup type to Manual and then re-run your code.