I use this script to get the results of a url:
@Echo off
For /f "delims=" %%A in (
'powershell -NonI -NoP -C "(Invoke-Webrequest "%~1").content"'
) Do set Line=%%A
I can call it in a command prompt window like this:
WebResponse.cmd "http://websiteremoved.com/teststat.php?username^=%friend1%"
I need to use the caret ( ^
) to cancel out the Equal sign. However when I run that same line of code in my batch file it does not work. According to the test, %~1 is set to "http://websiteremoved.com/teststat.php?username^=Lukaka"
but the powershell portion returns this:
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
Any ideas as to why it is doing this? Thanks a bunch!
The way I was doing it was inefficient. I am closing this question. I am working on a different version of a new script here: Add Multiple URLs to this Powershell Script? which is related.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.