CMD到PowerShell,运行带有XML的exe [英] CMD to PowerShell, run an exe with a XML
本文介绍了CMD到PowerShell,运行带有XML的exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将脚本从CMD移植到PowerShell,并习惯于使用以下内容:
I'm porting my scripts over to PowerShell from CMD and used to use the following:
start /wait Setup.exe /silent /play "path\filename.xml"
但是我无法将其转换为PowerShell.如何使用诸如/silent
和/play
之类的参数运行可执行文件?
I however am not able to convert this over to PowerShell. How do you run an executable with arguments like /silent
and /play
?
推荐答案
如果文件同步运行(即在完成前未返回),则可以简单地运行可执行文件:
If the file runs synchronously (i.e. doesn't return before completion) you could simply run the executable:
setup.exe /silent /play 'C:\path\to\filename.xml'
(可选)呼叫运算符:
& setup.exe /silent /play 'C:\path\to\filename.xml'
如果需要等待程序与控制台分离,则可以使用 Start-Process
cmdlet(别名为 start
):
If you need to wait for a program that detaches itself from the console you can use the Start-Process
cmdlet (alias start
):
Start-Process -Wait -FilePath setup.exe -ArgumentList '/silent', '/play', 'C:\path\to\filename.xml'
或(简称)
start -Wait setup.exe '/silent', '/play', 'C:\path\to\filename.xml'
这篇关于CMD到PowerShell,运行带有XML的exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文