2017-07-03 131 views
0

我使用这个脚本得到一个URL的结果:插入符不批处理文件的工作,工作在命令提示符

@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 

任何想法,为什么它这样做呢?谢谢一堆!

+2

你上次误会了我,我说要么**或**逃脱,而不是两个。 – LotPings

+0

为什么要使用'cmd.exe'?只需运行你想要直接从PowerShell提示符运行的命令。 –

+0

取决于您有多少内存可用。 ''cmd.exe 0.4MB'与'PowerShell 32MB'相比。 (需要80倍的内存才能打开PowerShell)当然,如果你有4G免费 - 谁在乎... –

回答

相关问题