【发布时间】:2016-02-19 12:07:46
【问题描述】:
var newProcessInfo = new System.Diagnostics.ProcessStartInfo();
newProcessInfo.FileName = @"C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe";
newProcessInfo.Verb = "runas";
newProcessInfo.Arguments = @"-executionpolicy unrestricted -Command ""C:\Windows\system32\sfc.exe /scannow""";
/*
newProcessInfo.Arguments = @"-Command ""sfc /scannow""";
newProcessInfo.Arguments = @"-File ""C:\my\script.ps1""";
newProcessInfo.Arguments = @"–ExecutionPolicy Bypass -File ""C:\my\script.ps1"""; */
这些基本上是我想要使用的基本样式代码命令。我一直有一个问题-executionpolicy unrestricted。当我像上面一样在 powershell 中键入它时效果很好。
另外,powershell 中与 cmd.exe /k 类似的编码是什么,以便命令提示符窗口保持打开以进行故障排除?
【问题讨论】:
标签: c# powershell command administrator