【发布时间】:2021-11-16 00:33:39
【问题描述】:
我正在编写一个批处理文件,并在这个批处理文件中执行一个脚本。
批处理文件:
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""C:\Public\File\SomeScript.ps1""' -Verb RunAs}"
现在可以正常工作了。
是否可以带参数执行 SomeScript.ps1 ?
喜欢
@echo off
echo %1
echo %2
echo %3
echo %4
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""C:\Public\File\SomeScript.ps1 Arg1 %1 Arg2 %2 Arg3 %3 Arg4 %4""' -Verb RunAs}"
批处理文件与我提供的值相呼应。但在那之后什么也没有发生。所以我不确定我是否正确传递了参数。
任何帮助表示赞赏:)
【问题讨论】:
标签: powershell batch-file parameters arguments script