我使用此脚本来获取网址的结果:
@Echo off
For /f "delims=" %%A in (
'powershell -NonI -NoP -C "(Invoke-Webrequest "%~1").content"'
) Do set Line=%%A
我可以在命令提示符窗口中调用它:
WebResponse.cmd "http://websiteremoved.com/teststat.php?username^=%friend1%"
我需要使用插入符号(^
)来取消等号。但是,当我在我的批处理文件中运行相同的代码行时,它不起作用。根据测试,%〜1设置为"http://websiteremoved.com/teststat.php?username^=Lukaka"
,但powershell部分返回:
Invoke-WebRequest : A positional parameter cannot be found that accepts argument 'Lukaka'. [] http://websiteremoved.com/teststat.php?username^=Lukaka
At line:1 char:2 [] http://websiteremoved.com/teststat.php?username^=Lukaka
+ (Invoke-Webrequest http://websiteremoved.com/teststat.p ... [] http://websiteremoved.com/teststat.php?username^=Lukaka
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ [] http://websiteremoved.com/teststat.php?username^=Lukaka
+ CategoryInfo : InvalidArgument: (:) [Invoke-WebRequest], ParameterBindingException [] http://websiteremoved.com/teststat.php?username^=Lukaka
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeWebRequestCommand [] http://websiteremoved.com/teststat.php?username^=Lukaka
关于它为什么这样做的任何想法?非常感谢!
答案 0 :(得分:0)
我这样做的方式效率低下。我正在结束这个问题。我在这里处理一个不同版本的新脚本:Add Multiple URLs to this Powershell Script?这是相关的。