views:

45

answers:

1

Is there a way to install services remotely, without necessarily resorting to .msi packages or full-blown installers? I'm currently using a method similar to the one discussed here:

http://stackoverflow.com/questions/358700/how-to-install-a-windows-service-programmatically-in-c

to install a service locally, and it works fine. However, I also need to be able to do the same thing remotely. I appreciate any insight.

+1  A: 

If you can copy the service binary (the exe file) to the destination computer you can install the service exactly in the same way as you do this locally. The only distinguish is that during the usage of OpenSCManager function (see http://msdn.microsoft.com/en-us/library/ms684323.aspx) you should use destination computer as the first parameter (lpMachineName) and in CreateService (see http://msdn.microsoft.com/en-us/library/ms682450.aspx) as a lpBinaryPathName you should place the path to your service exe how it looks like on the remote computer.

You can use sc.exe utility to do the installation (type" sc create /?" in the command prompt to receive help). The remote installation of the service which you can do with sc.exe you can implement with native Windows API like I short explain above.

Oleg