As discussed in other post, I came to know that Verb = "runas" works as elevated.
I need to run "logman.exe" arguments with Elevated privileged. With below code, I am not getting any output,
try
{
var process = new Process()
{
StartInfo = new ProcessStartInfo
{
FileName = "logman.exe",
Arguments = "PerfCounterCustom",
Verb = "runas",
RedirectStandardOutput = true,
CreateNoWindow = true,
}
};
process.Start();
string lineData;
while ((lineData = process.StandardOutput.ReadLine()) != null)
{
if (lineData.Contains("Root Path:"))
{
Console.WriteLine(lineData.Trim());
}
}
process.WaitForExit();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}
Note - When I am running above EXE, right click as Admin, I m getting the output.
What changes required so that I can make Elevated through code in C# and output?