powershell 从PowerShell运行CMD中的命令

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell 从PowerShell运行CMD中的命令相关的知识,希望对你有一定的参考价值。

$command = 'C:\somepath\someexe.exe somearg'
iex $command

#full working example
$command = 'cmd.exe /c "C:\Program Files (x86)\Bginfo\BgInfo.exe" "C:\Program Files (x86)\Bginfo\config_2016.bgi\" /silent /accepteula /timer:0'
iex "& $command"

#issue the command
cmd.exe /c dir /w

#leaves the argument untouched
cmd.exe --% /c dir %WINDIR% /w 

以上是关于powershell 从PowerShell运行CMD中的命令的主要内容,如果未能解决你的问题,请参考以下文章