我想在bat
文件中运行以下代码:
@echo off
echo ---------------------------------
ping -n 1 google.com | find "TTL=" >nul
if errorlevel 1 (
echo google = OFFLINE
) else (
echo google = ONLINE
)
然后我希望下面的代码也会在if errorlevel 1
中运行:
WshShell.AppActivate "Mozilla Firefox"
WshShell.SendKeys "google Offline"
WshShell.SendKeys "{ENTER}"
如何运行上面的代码?
最后一个代码通常在vbs
扩展名中运行,但我想在bat
扩展名中运行。
答案 0 :(得分:2)
这是“Frankenscript”;我喜欢这样一个词! ;)
@set @a=0; /*
@echo off
ECHO ---------------------------------
ping -n 1 google.com | find "TTL=" >nul
if errorlevel 1 (
echo google = OFFLINE
cscript //nologo //E:JScript "%~F0"
if NextSection == JScript ( */
WshShell = WScript.CreateObject("WScript.Shell");
WshShell.AppActivate("Mozilla Firefox");
WshShell.SendKeys("google Offline");
WshShell.SendKeys("{ENTER}"); /*
)
) else (
echo google = ONLINE
)
rem */