如何从 Windows 服务执行应用程序
我有window XP 2003服务器,它被放置在一个没人能进入登录的房间里。
用于监控某些应用程序 我创建了一个控制台应用程序 myServer.exe,它没有任何 UI, 我希望这个应用程序(例如,myServer.exe)在窗口启动时自动启动(例如,在窗口登录之前),
并且我需要使用 Windows 服务来完成这项工作。
(注意:请不要向我建议任何其他解决方案,我需要使用 Windows 服务来完成此任务)
I have window XP 2003 server, which is placed in a room where no one can enter to logon 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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
WinNT 资源工具包包括一个名为 SRVANY.EXE 的实用程序,可用于将任何应用程序作为服务运行。 ocdecio 的解决方案更好,但如果由于某种原因您无法重新设计应用程序 SRVANY.EXE 可能会起作用。 这是知识库文章。
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.
您可以直接用 C# 开发 Windows 服务。如果您有 Visual Studio Professional,则有一个用于 Windows 服务的内置项目模板。
MSDN 有一个使用 C# 创建服务的演练 清楚地解释了该过程。
如果您没有 Visual Studio Professional,您仍然可以创建服务。您只需要创建一个继承自
System.ServiceProcess.ServiceBase
。快速 Google 搜索发现了一些可能对您有帮助的其他链接:
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: