注意:我的电脑上启用了 Windows 沙盒。
Console.WriteLine(File.Exists(@"C:\Windows\system32\WindowsSandbox.exe"));
Console.WriteLine(new FileInfo(@"C:\Windows\system32\WindowsSandbox.exe").Exists);
运行上面的代码C# Interactive
在(VS 不在管理员模式下)
True
True
但是,当我在控制台应用程序中运行它时,(管理员模式和非管理员模式)。结果总是错误的。
False
False
我试过Process.Start(@"C:\Windows\system32\WindowsSandbox.exe")
了,控制台应用程序失败(管理员和非管理员),但 C# 交互成功。
在PowerShell中,C:\Windows\system32\WindowsSandbox.exe
成功启动了Windows Sandbox。在资源管理器(system32 文件夹)中:
图像
谁能解释为什么会发生这种情况?