在没有管理员权限的情况下运行taskmgr.exe?

时间:2019-09-22 14:58:11

标签: c# process

我需要使用我拥有的非常特定的代码来运行任务管理器,但是它出现访问拒绝错误。

我以前曾尝试以管理员模式运行。

FileStream fs = new FileStream(System.IO.Path.Combine(Environment.SystemDirectory, "taskmgr.exe"), FileMode.Open, FileAccess.ReadWrite, FileShare.None);

我想要的预期结果是任务管理器使用上面的代码打开,没有管理员权限! (反正还有吗?)

2 个答案:

答案 0 :(得分:2)

使用此:

using System.Diagnostics;

ProcessStartInfo startInfo = new ProcessStartInfo(); //a processstartinfo object
startInfo.CreateNoWindow = false; //just hides the window if set to true
startInfo.UseShellExecute = true; //use shell (current programs privillage)
startInfo.FileName = System.IO.Path.Combine(Environment.SystemDirectory, "taskmgr.exe"); //The file path and file name
startInfo.Arguments = ""; //Add your arguments here

Process.Start(startInfo);

资源:

答案 1 :(得分:1)

这是我拥有的启动过程功能

using System.Diagnostics;

private static void StartProcess(string exeName, string parameter)
{
    using (Process process = new Process())
    {
        process.StartInfo.FileName = exeName; 
        process.StartInfo.Arguments = parameter;
        process.EnableRaisingEvents = true;
        process.Start();
    }
}

然后称呼它

StartProcess("exename.exe", fileParameter);

Process Class