使用 WMI 提供程序无需安装 &海关总署注册
我想创建一个 .NET 应用程序,只要该应用程序正在运行,它就会启用我的 WMI 提供程序,并在关闭时禁用它。
有办法做到这一点吗?
我的最后一招是安装和安装关闭时重新安装。
请注意,我是 WMI 方面的专家,所以拜托,您甚至可以发布最琐碎和平庸的答案。
I want to create a .NET application that will enable my WMI provider as long as the application is running, and disable it on closing.
Is there a way of doing that?
My last resort is install & reinstall on closing.
Note that I'm a n00b in the ways of the WMI, so please, you can post even the most trivial and banal answers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为这是不可能的,因为 WMI 提供程序需要在 WMI 内注册(例如,拥有 __InstanceProviderRegistration 的实例)。要向其中添加 .NET 安装程序类型
DefaultManagementInstaller
将需要操作WMI配置数据,这需要提升。 (本机应用程序通常会直接使用 MOF 格式文件,但这仍然需要将文件复制到受保护的系统文件夹。)似乎没有进程内 WMI 提供程序的 .NET 4 示例,但有一个用于 . NET 3.5:http://msdn.microsoft.com/en -gb/library/bb885150(VS.90).aspx
I don't think it will be possible because a WMI provider needs to be registered within WMI (e.g. having an instance of
__InstanceProviderRegistration
). To add to these the .NET installer typeDefaultManagementInstaller
will need to manipulate the WMI configuration data, this requires elevation. (A native application would often use the MOF format file directly, but this still requires copying the file to a protected system folder.)There appears to be no .NET 4 sample of an in-process WMI provider, but there is one for .NET 3.5: http://msdn.microsoft.com/en-gb/library/bb885150(VS.90).aspx