作者:戴乐季206 | 来源:互联网 | 2023-10-09 18:59
篇首语:本文由编程笔记#小编为大家整理,主要介绍了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