繁体   English   中英

我如何在Powershell中使用大型多行脚本块启动进程?

[英]how i can start process with large multiline script block in powershell?

我想用脚本块启动进程powershell。 像这样的代码。

start-process powershell.exe -ArgumentList "-noexit","-command {
set-Set-ExecutionPolicy bypass -force
get-help get-process
get-command -commandtype cmdlet
...
}"

Command的参数应该是ArgumentList中的另一个未合并到-command中的元素。

Start-Process powershell.exe -ArgumentList "-noexit", "-command", "Get-Process"

无论您执行的是简单命令还是更长的命令(很长的字符串),这都适用。

您可以使用此方法:

Start-Process powershell.exe -ArgumentList "-noexit", "-command", "help
dir
get-command
" 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM