简体   繁体   中英

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.

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.

Use the SC command.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM