C# WMI 进程重启器
场景
我有一堆进程在服务器上运行,作为各种 C# 应用程序的一部分。 有时,其中一些会因某种原因而崩溃(我目前没有时间替换或重构旧的遗留代码)。
我的想法
是创建一个 C# 服务,不断检查这些进程是否正在运行,如果没有,则重新启动它们。
问题
有人提到 WMI 吗? - 有一个 C# 包装器吗? 本质上可以让你写作的东西。
Processes.GetProcessByName("MyProcess");
任何帮助、意见、建议,将不胜感激。
编辑:
我见过一个重新启动服务的示例,它使用 WindowsIdentity 来模拟用户,登录到服务器并重新启动服务......类似的东西会很棒,尽管我不知道如何甚至着手实施这一点。
Scenario
I have a bunch of processes running on a server as part of various C# Applications.
Occasionally some of these crash for whatever reason (old legacy code that I don't currently have the time to replace or refactor).
Idea
I want to create a C# Service that continually checks to see if these processes are running, and if not, restart them.
Questions
Someone mentioned WMI? - And something about there being a C# wrapper for this?
Something that essentially lets you write.
Processes.GetProcessByName("MyProcess");
any help, advice, suggestions, would be greatly appreciated.
EDIT:
I've seen an example of something that restarts Services, and it uses WindowsIdentity to impersonate a user, logon to a server and restart the services....Something similar would be fantastic, although I'm not sure how to even go about implementing this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
类似的事情?
Something like that?