I have window XP 2003 server, which is placed in a room where no one can enter to lo开发者_Python百科gon it.
for monitoring some applications I created a console application myServer.exe, which dont have any UI, I want that this application (e.g., myServer.exe) start automatically as window bootup (e.g., before window logon)
and I need to do this work using windows service.
(note: please don't suggest me any other solution, I need to use windows service to accomplish this task)
The WinNT resource kit includes a utility called SRVANY.EXE that can be used to run any application as a service. ocdecio's solution is better but if for some reason you can't redesign the app SRVANY.EXE may work. Here's the KB Article.
You can develop Windows services directly in C#. If you have Visual Studio Professional, there is a built-in project template for a Windows service.
MSDN has a walkthrough of creating a service with C# that explains the process clearly.
If you don't have Visual Studio Professional, you can still create a service. You'll just need to create a class that inherits from System.ServiceProcess.ServiceBase
manually.
A quick Google search turned up a couple of other links that may be helpful to you:
- http://www.codeproject.com/KB/system/WindowsService.aspx
- http://www.c-sharpcorner.com/UploadFile/mahesh/window_service11262005045007AM/window_service.aspx
精彩评论