13,871
社区成员




set ws=wscript.createobject("wscript.shell")
wscript.sleep 1000
ws.SendKeys "telnet{enter}"
Wscript.sleep 500
ws.SendKeys "set logfile aa.log{enter}"
Wscript.sleep 1000
ws.SendKeys "o 192.168.1.1{enter}"
Wscript.sleep 1000
ws.SendKeys "root{enter}"
wscript.sleep 1000
ws.SendKeys "password{enter}"
AnsiString strPath;
STARTUPINFO StartInfo;
PROCESS_INFORMATION procStruct;
memset(&StartInfo, 0, sizeof(STARTUPINFO));
StartInfo.cb = sizeof(STARTUPINFO);
StartInfo.dwFlags =STARTF_USESHOWWINDOW;
StartInfo.wShowWindow = SW_HIDE;
strPath = "telnet.exe -f aaa.log 192.168.1.1";
bool b = CreateProcess(NULL, strPath.c_str(), NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &StartInfo, &procStruct);
if (b)
{
Sleep(1000);
if (hTelnet = ::FindWindow("ConsoleWindowClass", "Telnet 192.168.1.1")) // 找到控制台句柄
{
。。。。。
}
}
Sleep(100);
PostMessage(hTelnet, WM_CHAR, 'A' , 0); // ' 发送一个 字符