开发者

Windows Service Installation

开发者 https://www.devze.com 2022-12-28 00:16 出处:网络
Scenario I have a server, that has NO Visual Studio Installed. It literally开发者_运维技巧 has a normal command prompt and nothing installed yet. We don\'t want to install anything (except the .Net fr

Scenario

I have a server, that has NO Visual Studio Installed. It literally开发者_运维技巧 has a normal command prompt and nothing installed yet. We don't want to install anything (except the .Net framework which we have already done). We just want to install a bunch of C# Windows Services that we have written.

So far

I have been installing and running the windows service on my local machine using a "setup and deploy" project that I built into the application, which I could then use to install the service locally.

Question

How can I install the service on the server? I imagine it can be done from the command prompt only, but what else do I need? - If anything? and where do I put the files that I want to install BEFORE I install them? I imagine I will have to compile the application on my local machine in Visual Studio, then copy it over to the server, and then run an install utility to install it on the server?

Any help would be greatly appreciated.


according to this thread you need to run

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe C:\MyService.exe

(replace c:\windows with your windows path)


Your server has a sc.exe (service control) command which allows you to install, uninstall, start, stop and configure services - no Visual Studio bits needed.

Run sc.exe -? at a command prompt to get a listing of all available options


I add code similar to the one in this article to my services:

http://www.codeproject.com/KB/dotnet/WinSvcSelfInstaller.aspx

Then I can install/uninstall them just by typing ServiceName -i or ServiceName -u at the command prompt. Makes it easier if it'll be installed by people who don't know .Net.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号