我已经从whitin a c#应用程序执行了命令 bcdedit /set current safeboot network
,并且在我在终端中遇到的错误中执行了命令:
未识别指定的元素数据类型,或不适用于指定条目。运行" 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();
问题是我缺少围绕"当前"一词的括号:
startInfo.Arguments = @"/C bcdedit /set {current} safeboot network & ping 8.8.8.8 -t";