C# - 检查设备问题和系统问题
在 C# 中,我如何检查设备和系统错误?使用 PowerShell Scipts 会很简单,还是会增加复杂性和难度?
In C#, How Could I go about checking for device and systems errors? Would it be simple to use PowerShell Scipts, or would that add to the complexity and difficulty?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于 Windows 7 客户端,请查看Windows 故障排除平台。这是下载 上有更多详细信息。它使用 PowerShell 脚本来完成您所说的操作。此博客文章 展示了如何编写故障排除包 - 这非常简单。
我认为 WTP 不适用于下层平台。在这种情况下,我只需编写一些 PowerShell 脚本来检测并修复根本原因。如果您想将其包装在一个漂亮的 UI 中,请查看 PowerBoots - 创建 WPF 的简单方法GUI 位于脚本之上。如果您想在基于 C# 的 GUI 中托管 PowerShell,这非常简单。下面是来自 Forms 应用程序的代码片段:
您需要添加对 System.Management.Automation 程序集的引用。如果您已安装 Windows/.NET SDK,则该 SDK 应该位于 ProgramFiles\ReferenceAssemblies\Microsoft\WindowsPowerShell\v1.0 中。您还需要一些使用状态:
For Windows 7 clients check out the Windows Troubleshooting Platform. Here is a download on it with more details. It uses PowerShell scripts to do exacty what you're talking about. This blog post shows how to author a troubleshooting pack - it's pretty easy.
I don't think WTP works on downlevel platforms. In this case, I would just write some PowerShell scripts to detect and fix root causes. If you want to wrap that up in a nice UI, check out PowerBoots - an easy way to create a WPF GUI on top of your script. If you want to host PowerShell in your on C#-based GUI it is very simple. Here's a code snippet from a Forms app:
You need to add a reference to the System.Management.Automation assembly. If you have installed the Windows/.NET SDK that should be in ProgramFiles\ReferenceAssemblies\Microsoft\WindowsPowerShell\v1.0. You will also need a couple of using statememets: