I am trying to reboot several devices on my private network through telnet. I wrote a vbs that does the operation but i cannot select any other window while it is running of the input will not go into the telnet window created. I have begun to convert the code to C++ and am having problems I can get telnet to open to the ip address that I want but do not know how to pass any commands to it. I have read about 30 different website and people say how you do it but noone has provided any sample code of how it would work. Here is the code that I have so far.
as i said i have started to convert it but have not finished it gets to the login name part of the telnet session and I do not know how to take my information from the program.
Code:
#include <windows.h>
#include <string>
#include <iostream>
#include <comdef.h>
#include <atlbase.h>
using namespace std;
string ipaddress;
string rebootradio (string);
int main()
{
string telnetid, telnetpw;
telnetid = "xxxx";
telnetpw = "xxxx";
rebootradio ("192.168.1.2");
rebootradio ("192.168.1.3")
rebootradio ("192.168.1.4")
rebootradio ("192.168.1.5")
rebootradio ("192.168.1.6")
rebootradio ("192.168.1.9")
rebootradio ("192.168.1.11")
rebootradio ("192.168.1.12")
rebootradio ("192.168.1.13")
rebootradio ("192.168.1.14")
rebootradio ("192.168.1.15")
rebootradio ("192.168.1.16")
rebootradio ("192.168.1.17")
rebootradio ("192.168.1.18")
rebootradio ("192.168.1.19")
rebootradio ("192.168.1.20")
rebootradio ("192.168.1.21")
rebootradio ("192.168.1.22")
rebootradio ("192.168.1.30")
rebootradio ("192.168.1.31")
rebootradio ("192.168.1.32")
rebootradio ("192.168.1.33")
rebootradio ("192.168.1.34")
rebootradio ("192.168.1.35")
rebootradio ("192.168.1.36")
rebootradio ("192.168.1.37")
system ("Pause");
return 0;
}
string rebootradio (string ipaddress)
{
system (("Telnet " + ipaddress).c_str());
("lego");
system ("mania");
wshShell.SendKeys "iden radio 1 reset on{ENTER}" 'repeat as needed
wscript.Sleep 2000
wshShell.SendKeys "iden radio 2 reset on{ENTER}" 'repeat as needed
wscript.Sleep 2000
wshShell.SendKeys "exit{ENTER}" 'close telnet session'
wscript.Sleep 2000
wshShell.SendKeys "{ENTER}" 'get command prompt back
wscript.Sleep 2000
wshShell.SendKeys "exit{ENTER}" 'close cmd.exe
}