BondEtwSample.Program.StartEtw C# (CSharp) Method

StartEtw() static private method

static private StartEtw ( ) : void
return void
        static void StartEtw()
        {
            var principal = new WindowsPrincipal(WindowsIdentity.GetCurrent());
            if (!principal.IsInRole(WindowsBuiltInRole.Administrator))
            {
                throw new Exception("To enable ETW tracing you must be administrator");
            }

            StopEtw();

            var cmd = "create trace " + sessionName + " -nb 2 2 -bs 1024 -p " + providerId + "  0xffffffffffffffff -o " + sessionName + ".etl -ets";
            var logman = Process.Start("logman.exe", cmd);
            logman.WaitForExit();
        }