当我运行这个Powershell命令时,它在我的Windows 7 PC上工作,但在我的Windows 10 PC上却不能工作,为什么呢?
cmd /c "`"`"C:\Program Files (x86)\National Instruments\LabVIEW 2018\LabVIEW.exe`"`""错误是
'""C:\Program' is not recognized as an internal or external command, operable program or batch file.命令
cmd /c "`"C:\Program Files (x86)\National Instruments\LabVIEW 2018\LabVIEW.exe`""这两种方法都可以使用,但我必须添加另一对引号,因为我的命令实际上包含路径:
cmd /c "`"`"C:\Program Files (x86)\National Instruments\LabVIEW 2018\LabVIEW.exe`" `"$runner_File`" > `"$runnerResult_File`"`""发布于 2019-02-25 17:01:54
避免引用头痛
cmd.exe的>重定向和Set-Content -Encoding Oem。& "C:\Program Files (x86)\National Instruments\LabVIEW 2018\LabVIEW.exe" $runner_File |
  Set-Content -Encoding Oem $runnerResult_File请继续阅读以得到解释。
如果您确实想用cmd /c解决最初的问题,请参阅下面的部分。
cmd /c从PowerShell调用控制台应用程序。- Piping to `Set-Content -Encoding Oem` can be used to emulate `cmd.exe`'s `>` output redirection, though note that this may slow things down.    - On the plus side, `Set-Content` allows you to _control_ the output encoding.
- To control what character encoding PowerShell assumes the console application's output uses, set `[Console]::OutputEncoding` _before_ invoking the application.
- While you could use PowerShell's own `>`, it would create UTF-16LE files by default in Windows PowerShell (and BOM-less UTF-8 files in PowerShell _Core_) - though in PSv5.1+ you can [change the encoding that `>` uses](http://stackoverflow.com/a/42451413/45375) via the `$PSDefaultParameterValues` dictionary of presets.
&。$runnerFile)提供参数,PowerShell将在需要时在幕后为您引用变量值。用cmd /c解决问题
奇怪的是,将包含多个cmd /c参数的命令行传递给 "..."**-enclosed ,需要在** "...".中封装_E 251完整的E 152>E 253命令行。
以下是如何通过PowerShell实现这一目标:
"实例(`")放在传递给cmd /c的命令行的两端,这将成为整个"..."的封闭部分。cmd /c `" "C:\Program Files (x86)\National Instruments\LabVIEW 2018\LabVIEW.exe" $runner_File > $runnerResult_File `"https://stackoverflow.com/questions/54870984
复制相似问题