【问题标题】:How can the argument to a batch file be intrun passed onto a powershell script?如何将批处理文件的参数内部传递到 powershell 脚本?
【发布时间】:2013-02-16 04:19:34
【问题描述】:

我正在尝试通过 bat 文件调用 powershell 脚本,如下所示;

Bat 文件名为 Script .bat,当前文件名如下;

Powershell -sta -Windowstyle Hidden Script.Ps1

我正在将一个参数传递给 bat 文件,我如何将它传递给 bat 文件中的 powershell 脚本?

如果需要任何问题或确认,请告诉我。

【问题讨论】:

    标签: powershell batch-file arguments argument-passing


    【解决方案1】:

    在你的shell脚本(批处理文件)中,你可以写:

    powershell -file script.ps1 %1
    

    %1 将替换为 shell 脚本的第一个命令行参数,它将作为第一个参数传递给 script.ps1。

    比尔

    【讨论】:

      猜你喜欢
      • 2011-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-01-23
      • 1970-01-01
      • 2015-08-18
      • 2017-02-11
      相关资源
      最近更新 更多