【发布时间】:2018-01-26 12:42:18
【问题描述】:
我正在从一个批处理文件中调用一个 powershell 脚本,这两个文件都在不同的位置。
我想从该批处理文件传递 powershell 脚本文件的文件夹位置以及参数,即用户在批处理文件中输入的字符串。
powershell 脚本:
$url = "https://www.ons.gov.uk/generator?format=csv&uri=/economy/inflationandpriceindices/timeseries/chaw/mm23"
$output="sample.csv"
$start_time = Get-Date
$arg1=$args[0]
Invoke-WebRequest -Uri $url -OutFile $arg1\$output
Write-Output "Time taken: $((Get-Date).Subtract($start_time).Seconds) second(s)"
我的批处理文件:
powershell.exe -ExecutionPolicy Bypass -file C:\temp\download-rpi.ps1 "\\drives\savehere"
【问题讨论】:
-
为什么需要批处理文件?只需从 PowerShell 提示符运行脚本。
-
@Bill_Stewart 因为他只能从第三方软件调用批处理。
-
也许,但问题中没有说明。
-
@Bill_Stewart 他没有,不,他只在下面的 cmets 中提到了答案。
标签: powershell batch-file