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 UserRank #1,422 · 1.2K reputationPosted Dec 29, 2010, 8:38 AM EST
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.
Guest UserRank #1,422 · 1.2K reputationPosted Dec 29, 2010, 6:43 AM EST
Try changing the startup type to Manual and then re-run your code.
Jason31 reputationPosted Dec 29, 2010, 6:53 AM EST
Jason31 reputationPosted Dec 29, 2010, 8:52 AM EST
Guest UserRank #1,422 · 1.2K reputationPosted Dec 29, 2010, 9:03 AM EST
Can you ping that server using the same name as your MachineName setting?
Jason31 reputationPosted Dec 29, 2010, 9:11 AM EST
Guest UserRank #1,422 · 1.2K reputationPosted Dec 29, 2010, 9:18 AM EST
If you have a minute, could you mark my reply as the accepted answer? I'd appreciate it!
Jason31 reputationPosted Dec 29, 2010, 10:27 AM EST