0

I am wondering if there's a Managed equivalent of functionality provided by CreateService() or ChangeServiceConfig() for Services on a remote host?

Service Installer class appears to only operate locally.

Dan S
  • 9,139
  • 3
  • 37
  • 48

1 Answers1

1

I would recommend looking at this existing question: Installing a windows service on a remote machine using a given username.

In this answer they mention using "SC.exe". This is a tool in windows that allows you to "create and start a service". You should easily be able to run this program using the Process class in System.Diagnostics. For example here is code, based on the example by Patrick McDonald, that would start NewServ.exe on the computer "remotecomputer".

Process process = new Process();
process.Start(@"C:\Windows\System32\SC.exe", @"\\remotecomputer create newservice binpath= C:\Windows\System32\Newserv.exe start= auto obj= DOMAIN\username password= pwd");

If this doesn't work, then you should be able to create your own installer, copy it to the remote computer, and then start the process remotely. See this question for more details: How to execute a process on a remote machine, in c#

Community
  • 1
  • 1
Aaron Viviano
  • 306
  • 2
  • 6
  • I was hoping to avoid using a separate command line utility but sc.exe is a great at doing remote and local. – Dan S Aug 26 '13 at 22:39
  • Understandable, but at least this is a solution. If you have chance, can you please mark my answer as correct, if it solves your problem? Thank you. – Aaron Viviano Aug 26 '13 at 22:48