系统无法在Process Start(tscon.exe)中找到指定Exception的文件

use*_*174 4 c# process

我在tscon上的Process.Start中得到"系统找不到指定Exception的文件"

工作:

Process.Start(new ProcessStartInfo(@"c:\Windows\System32\notepad.exe", "temp.txt"));
Run Code Online (Sandbox Code Playgroud)

不工作:

Process.Start(new ProcessStartInfo(@"c:\Windows\System32\tscon.exe", @"0 /dest:console"));
Run Code Online (Sandbox Code Playgroud)

我需要tscon.exe.为什么我会收到此错误?

编辑:

  1. 验证tscon.exe确实在c:\Windows\System32文件夹中.
  2. 我在管理员模式下运行VS.

该文件有一些强化吗?无法理解这一点......

Ste*_*eve 7

哦,这件事真的引起了我的注意.
我终于设法从Process.Start启动tscon.exe.
您需要传递"管理员"帐户信息,否则会收到"找不到文件"错误.

这样做

ProcessStartInfo pi = new ProcessStartInfo();
pi.WorkingDirectory = @"C:\windows\System32"; //Not really needed
pi.FileName = "tscon.exe";
pi.Arguments = "0 /dest:console";
pi.UserName = "steve";
System.Security.SecureString s = new System.Security.SecureString();
s.AppendChar('y');
s.AppendChar('o');
s.AppendChar('u');
s.AppendChar('r');
s.AppendChar('p');
s.AppendChar('a');
s.AppendChar('s');
s.AppendChar('s');
pi.Password = s;
pi.UseShellExecute = false; 
Process.Start(pi);
Run Code Online (Sandbox Code Playgroud)

还要看到命令的结果改变以下两行

pi.FileName = "cmd.exe";
pi.Arguments = "/k \"tscon.exe 0 /dest:console\"";
Run Code Online (Sandbox Code Playgroud)