Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
设置批处理脚本以运行带参数的powershell_Powershell_Batch File - Fatal编程技术网

设置批处理脚本以运行带参数的powershell

设置批处理脚本以运行带参数的powershell,powershell,batch-file,Powershell,Batch File,我有一个PowerShell脚本,它接受参数/命令并在PowerShell中执行良好。我正在考虑设置一个批处理脚本来运行以下命令,就像模拟PowerShell一样 (-config是在脚本中定义的函数) 我写了一个批处理脚本,比如 ECHO OFF POWERSHELL.EXE -file "C\temp\power_t1.ps1 -config d:\temp\dirlist.txt" 但这似乎不起作用 有什么建议吗 问候,, Ruben脚本文件和脚本文件的参数是powershell.ex

我有一个PowerShell脚本,它接受参数/命令并在PowerShell中执行良好。我正在考虑设置一个批处理脚本来运行以下命令,就像模拟PowerShell一样

(-config是在脚本中定义的函数)

我写了一个批处理脚本,比如

ECHO OFF
POWERSHELL.EXE -file "C\temp\power_t1.ps1 -config d:\temp\dirlist.txt" 
但这似乎不起作用

有什么建议吗

问候,,
Ruben

脚本文件和脚本文件的参数是
powershell.exe的独立参数。如果查看
powershell.exe/?
,在
-文件下,您会看到:

文件必须是命令中的最后一个参数,因为在文件参数名称之后键入的所有字符都被解释为脚本文件路径,后跟脚本参数

尝试:


基本上,将
-File
参数之后的所有内容或多或少地视为是在PowerShell中与呼叫接线员(
&
)一起编写的。

您好,感谢您的快速响应,我也尝试了该选项,但对我无效。如果我正在使用Powershell,我将简单地执行此操作。。。。[c:\Temp\power\u t1.ps1-config d:\Temp\dirlist.tst]并执行脚本。我正在尝试设置启动powershell命令并运行整个命令的批处理脚本
ECHO OFF
POWERSHELL.EXE -file "C\temp\power_t1.ps1 -config d:\temp\dirlist.txt" 
POWERSHELL.EXE -File "C\temp\power_t1.ps1" -config d:\temp\dirlist.txt