正如在其他帖子中所讨论的,我开始知道 Verb = "runas" 可以提升。
我需要以高权限运行“logman.exe”参数。使用下面的代码,我没有得到任何输出,
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());
}
注意 - 当我在 EXE 上运行时,以管理员身份右键单击,我得到了输出。
需要进行哪些更改才能通过 C# 中的代码和输出进行提升?
PIPIONE
相关分类