更新时间:2021-09-11 05:21:07
试试这个:
$app = 'app.exe -help'
Invoke-Expression $app
用这个测试,它按预期工作:
Tested with this and it worked as expected:
$pingTest = 'ping -n 8 127.0.0.1'
Invoke-Expression $pingTest
根据您的扩展说明,您似乎想要在同一命令提示符下运行 2 个命令.这是可能的,但是,我不确定它是否适用于您的场景.例如:
From your expanded explanation you appear to want to run 2 commands within the same command prompt. This is possible, however, I'm not sure it will work in your scenario. For example:
test1.bat:回声你好!"
test2.bat: echo "goodbye!"
test2.bat: echo "goodbye!"
$batchTest = "test1.bat && test2.bat"
cmd /c $batchTest
输出:
D:\Test>echo "hello!"
"hello!"
D:\Test>echo "goodbye!"
"goodbye!"
希望这会有所帮助.