我使用批处理文件来检查mysql站点的状态。现在一切都在网站方面很好用,所以当我连接到它时,它会说User is Online
或Offline
之类的东西。需要一个批处理文件来调用url 并将页面输出保存到文本文件。这篇文章按照我要求而不保存输出:Open a URL without using a browser from a batch file。它可以是一个vbscript,只要它可以通过批处理文件调用。非常感谢!
以上帖子的原始文字:
@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);
答案 0 :(得分:1)
如果您不介意使用批处理中的powershell:
:: WebResponse.cmd
@Echo off
For /f "delims=" %%A in (
'powershell -NonI -NoP -C "(Invoke-Webrequest "%~1").content"'
) Do Echo one line of Webresponse %%A
示例输出,其网址为get your current external IP
> WebResponse.cmd "http://api.ipify.org"
one line of Webresponse 93.226.203.xxx