gpt4 book ai didi

windows - 在 -ArgumentList 中启动进程变量

转载 作者:可可西里 更新时间:2023-11-01 10:58:03 25 4
gpt4 key购买 nike

我想知道是否有更专业的人可以帮助我解决我在 -ArgumentList 中使用变量时遇到的小问题使用 Start-Process 时.

如果我在不使用 Start-Process 的情况下运行 Exe

.\DeploymentServer.UI.CommandLine.exe register --estNumber $Number --postcode $PostCode --password $Password

一切正常,命令运行并且软件已注册。

如果我尝试

Start-Process .\DeploymentServer.UI.CommandLine.exe -ArgumentList "register --estNumber $Number --postcode $PostCode --password $Password" -Wait -NoNewWindow

$Arguments = "register --estNumber $Number --postcode $PostCode --password $Password"
Start-Process .\DeploymentServer.UI.CommandLine.exe -ArgumentList $Arguments -NoNewWindow -Wait

命令运行但无法注册,说明它无法匹配提供的详细信息。所以我假设问题在于将参​​数传递给 Start-Process , 或 -ArgumentList解释字符串中的变量。我在这里错过了一些非常简单的东西吗?可能与 $ 有关在-ArgumentList

最佳答案

$postcode 中有一个空格,因此您需要将参数放在引号中:

Start-Process .\DeploymentServer.UI.CommandLine.exe -ArgumentList "register --estNumber $Number --postcode `"$PostCode`" --password $Password" -Wait -NoNewWindow

关于windows - 在 -ArgumentList 中启动进程变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35117204/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com