.net o使用此工具调整WMI权限:

.net o使用此工具调整WMI权限: ,.net,perfmon,.net,Perfmon,用法: WmiSecurity.exe /C="%computername%" /A /N=Root/CIMV2 /M=" DOMAIN\USER:REMOTEACCESS" /R 这是哪个版本的.Net?已经有一段时间了,但我很确定我当时使用的是.Net 2.0或3.5。你有没有得到答案?我想知道您是否创建了一个自定义性能计数器类,但它不可序列化?没有。我不再处于相同的位置,因此无法再在相同的环境中确认/也许是许可证什么的? var pc = new PerformanceCounter(c

用法:

WmiSecurity.exe /C="%computername%" /A /N=Root/CIMV2 /M=" DOMAIN\USER:REMOTEACCESS" /R

这是哪个版本的.Net?已经有一段时间了,但我很确定我当时使用的是.Net 2.0或3.5。你有没有得到答案?我想知道您是否创建了一个自定义性能计数器类,但它不可序列化?没有。我不再处于相同的位置,因此无法再在相同的环境中确认/也许是许可证什么的?
var pc = new PerformanceCounter(category_name, counter_name, instance_name, false);
while (true) {
   pc.RawValue = 0;
   Thread.Sleep(1000);
}
// Based on the MSDN-supplied C# example from:
// Adding and Removing Performance Counter Instances
// http://msdn.microsoft.com/en-us/library/8t39y5k1%28v=VS.71%29.aspx
using System;
using System.Diagnostics;
using System.Threading;

namespace CustomPerformanceCounters
{
    class Program
    {
        private const string categoryName = "Instance Category";
        private const string categoryHelp = "Instanced counter demonstration for StackOverflow.";
        private const string counterName = "Instance Counter";
        private const string counterHelp = "Instanced counter demonstration for StackOverflow.";

        static void RegisterCounter()
        {
            if (!PerformanceCounterCategory.CounterExists(counterName, categoryName))
            {
                PerformanceCounterCategory.Create(
                    categoryName
                    , categoryHelp
                    , PerformanceCounterCategoryType.MultiInstance
                    , counterName
                    , counterHelp
                    );
            }

        }

        static void RunCounter()
        {
            const string instance1 = "instance1";
            const string instance2 = "instance2";
            const string instance3 = "instance3";

            // Assumes category and counter have been created.
            PerformanceCounter myCounter = new PerformanceCounter(
                categoryName
                ,counterName
                , instance1
                , false
                );

            int currentValue = 0;
            int currentIncrement = 1;
            while (true)
            {
                currentValue += currentIncrement;
                if (currentValue > 99)
                {
                    currentIncrement = -1;
                }
                else if (currentValue < 1)
                {
                    currentIncrement = 1;
                }
                int instance1Value = currentValue;
                int instance2Value = 100 - currentValue;
                int instance3Value = Math.Abs(instance1Value - instance2Value);
                Console.WriteLine("Current values: {0}, {1}, {2}", instance1Value, instance2Value, instance3Value);

                myCounter.InstanceName = instance1;
                myCounter.RawValue = instance1Value;
                myCounter.InstanceName = instance2;
                myCounter.RawValue = instance2Value;
                myCounter.InstanceName = instance3;
                myCounter.RawValue = instance3Value;

                Thread.Sleep(1000);
            }
        }

        static void Main(string[] args)
        {
            RegisterCounter();
            RunCounter();
        }
    }
}
WmiSecurity.exe /C="%computername%" /A /N=Root/CIMV2 /M=" DOMAIN\USER:REMOTEACCESS" /R