我想使用 VBS 或 BATCH 文件发送自动 URL 请求。 该请求将具有以下结构:http://myServeurIP/Test/?name=ezioauditore
我找到了这篇文章,对我有帮助:Open a URL without using a browser from a batch file
@if (@This==@IsBatch) @then
@echo off
rem **** batch zone *********************************************************
setlocal enableextensions disabledelayedexpansion
rem Batch file will delegate all the work to the script engine
if not "%~1"=="" (
wscript //E:JScript "%~dpnx0" %1
)
rem End of batch area. Ensure batch ends execution before reaching
rem javascript zone
exit /b
@end
// **** Javascript zone *****************************************************
// Instantiate the needed component to make url queries
var http = WScript.CreateObject('Msxml2.XMLHTTP.6.0');
// Retrieve the url parameter
var url = WScript.Arguments.Item(0)
// Make the request
http.open("GET", url, false);
http.send();
// All done. Exit
WScript.Quit(0);
但是我不明白。什么是 "%~1"==""
?
我将 URL 放入 http.send(http://myServeurIP/Test/);
中。这是对的吗 ?
我也不知道它是否有效。
你能帮我理解这个脚本吗?
最佳答案
@end 上面的所有内容并不特定于当前的问题...这是一种使脚本可以作为批处理文件或直接作为脚本运行的方法。
如果您想对脚本中的 URL 进行硬编码,并使用显式的“wscript.exe _script_//E:Jscript
”运行它,它可以短得多,比如就像下面这样...
var http = WScript.CreateObject('Msxml2.XMLHTTP.6.0');
http.open("GET", "http://myServeurIP/Test/", false);
http.send();
WScript.Quit(0);
关于javascript - 如何使用VBS或BAT脚本发送url请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35083872/