删除Windows性能计数器类别 [英] Deleting Windows performance counter categories

查看:95
本文介绍了删除Windows性能计数器类别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义性能计数器类别. Visual Studio Server Explorer拒绝删除它,声称它未注册或系统类别".缺少以编程方式进行的操作,如何删除类别?有可以删除的注册表项吗?

I have a custom performance counter category. Visual Studio Server Explorer refuses to delete it, claiming it is 'not registered or a system category'. Short of doing it programmatically, how can I delete the category? Is there a registry key I can delete?

推荐答案

据我所知,除了以编程方式(它们是供应用创建和使用的,在安装过程中删除),但是在 PowerShell 命令行控制台中进行操作很简单.只需运行以下命令:

As far as I know, there is no way to safely delete them except programatically (they're intended for apps to create and remove during install) but it is trivial to do from a PowerShell command-line console. Just run this command:

[Diagnostics.PerformanceCounterCategory]::Delete( "Your Category Name" )

如何:(编辑)

可以删除创建的注册表项,这将使类别消失.

You can delete the registry key that's created, and that will make the category vanish.

对于名为广告资源"的类别,您可以在HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Inventory处删除整个密钥,尽管我不愿意打赌清理所有内容,但 使类别消失. (如果您在运行Delete()方法的同时运行进程监视器,则您可以看到还有很多其他活动正在发生,并且似乎没有进行任何其他更改.

For a category called "Inventory" you can delete the whole key at HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Inventory ... and although I wouldn't be willing to bet that cleans up everything, it will make the category disappear. (If you run Process Monitor while running the Delete() method, you can see can a lot of other activity happening, and there doesn't seem to be any other changes made).

请务必注意,我最初说的:当您从Visual Studio中收到该错误时,可能是它已被删除,您需要在VS中刷新视图.在测试中,我必须重新启动应用程序才能使它们真正获得可用类别的完整列表.

It's important to note that as I said originally: when you get that error from Visual Studio, it might be that it's already deleted and you need to refresh the view in VS. In my testing, I had to restart applications in order to get them to actually get a clean list of the available categories.

您可以从PowerShell中查看类别的完整列表,以查看是否列出了该类别:

You can check the full list of categories from PowerShell to see if it's listed:

[Diagnostics.PerformanceCounterCategory]::GetCategories() | Format-Table -auto

但是,如果您检查它们,然后删除注册表项...它们仍会显示,直到重新启动PowerShell(如果您启动另一个实例,则可以在该实例上运行相同的查询,并且不会显示该查询)已删除的项目,但在第一个项目中重新运行GetCategories将继续显示该项目.

But if you check them, then delete the registry key ... they'll still show up, until you restart PowerShell (if you start another instance, you can run the same query over there, and it will NOT show the deleted item, but re-running GetCategories in the first one will continue showing it.

顺便说一句,如果要对样式使用-like或对完整正则表达式使用-match,则可以过滤该列表:

By the way, you can filter that list if you want to using -like for patterns, or -match for full regular expressions:

[Diagnostics.PerformanceCounterCategory]::GetCategories() | Where {$_.CategoryName -like "*network*" } | Format-Table -auto
[Diagnostics.PerformanceCounterCategory]::GetCategories() | Where {$_.CategoryName -match "^SQL.*Stat.*" } | Format-Table -auto

这篇关于删除Windows性能计数器类别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆