Rune Hansen
Rune Hansen

Reputation: 1024

How to install a C# Windows Service on a remote server?

Hi I have developed a C# Windows Service in Visual Studio. I am able to install this service on my local machine and it works fine. Now I want to be able to install it on a remote server.

Can you tell me how to do this?

My service is just built on the Windows Service VS template, so it's all very simple.

I am not so geeky, so it would be useful with some tutorial, manual which I can understand.

I am running VS 2010 Professional.

Upvotes: 15

Views: 27497

Answers (2)

Akram Shahda
Akram Shahda

Reputation: 14781

Use the SC command.

sc \\remotecomputer create newservice binpath= C:\Windows\System32\Newserv.exe 
   start= auto obj= DOMAIN\username password= pwd

Upvotes: 9

rtpHarry
rtpHarry

Reputation: 13125

You need to have Remote Desktop access to the server.

When you are in you can do it via the commandline using something like this:

C:\Windows\Microsoft.NET\Framework\v2.0.50727\installutil /LogToConsole=true C:\Path\To\Service.exe

Then you can manage it (start it, set it to auto start, stop it, restart it) by going to Start | Run and typing

services.msc

then press enter.

To uninstall it use:

C:\Windows\Microsoft.NET\Framework\v2.0.50727\installutil /u /LogToConsole=true C:\Path\To\Service.exe

But you will need to have stopped the service first.

Note: There is probably a new util in newer .net releases - my notes are from a while ago when I built a 2.0 service. Look in C:\Windows\Microsoft.NET\Framework\ for a version number that matches the .net you're developing in.

Upvotes: 20

Related Questions