首页 > 解决方案 > 运行“bcdedit /?” 命令行帮助

问题描述

我已经bcdedit /set current safeboot network从一个 C# 应用程序中执行了命令,这在我在终端中遇到的错误中:

指定的元素数据类型无法识别,或不适用于指定的条目。运行“bcdedit /?” 用于命令行帮助。未找到元素。


这是我的代码:

System.Diagnostics.Process process = new System.Diagnostics.Process();
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Normal;
startInfo.FileName = "cmd.exe";
startInfo.UseShellExecute = true;
startInfo.Verb = "runas";
startInfo.Arguments = @"/C  bcdedit /set current safeboot network & ping 8.8.8.8 -t";
//startInfo.Arguments = "/C ping 8.8.8.8 -t";
process.StartInfo = startInfo;
process.Start();

标签: c#cmd.net-core

解决方案


问题是我错过了“当前”这个词周围的括号:

startInfo.Arguments = @"/C  bcdedit /set {current} safeboot network & ping 8.8.8.8 -t";

推荐阅读