access 192.168.0.1 with CMD

I need some help to create a .bat file which need to:

1) Access 192.168.0.1 or tplinklogin.net (my wi-fi router address)

2) Type/insert user and password

3) Click/run "Disconnect" wait 1-3 sec

4) Click/run "Connect" wait 3-5 sec

5) Click/run "Refresh" - not really necessary

6) Exit

6

1 Answer

I found this link, which seems more or less to answer the problem, though the Linux script above it worked rather better. I found that the process termination code towards the end didn't work properly, so I took it out and all was well. I also changed the service commands in line with the discussion below and finished up with:-

set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd"
WScript.Sleep 100
WshShell.AppActivate "C:\Windows\system32\cmd.exe"
WScript.Sleep 1000
WshShell.SendKeys "telnet 192.168.0.1~"
WScript.Sleep 1000
WshShell.SendKeys "admin~"
WScript.Sleep 1000
WshShell.SendKeys "admin~"
WScript.Sleep 2000
WshShell.SendKeys "wan set service pppoa_0_38_0_d --protocol pppoa --conntrigger manual~"
WScript.Sleep 12000
WshShell.SendKeys "~"
WScript.Sleep 1000
WshShell.SendKeys "wan set service pppoa_0_38_0_d --protocol pppoa --conntrigger always~"
WScript.Sleep 6000
WshShell.SendKeys "~"
WScript.Sleep 1000
WshShell.SendKeys "logout~"
WScript.Sleep 6000
WshShell.SendKeys "~"
WScript.Sleep 1000
WshShell.SendKeys "exit~"

You simply copy this to a file with a .vbs suffix, edit it to update the router's IP address, the log-in user and password, and the service name and protocol. For the latter you will need to log into telnet manually and type:

wan show service

In your cmd script, invoke the edited script with:

start [/wait] reconnect.vbs

Use /wait if you want the script to complete before you continue to the next command.

One problem I found is that if called while the router is on-line it leaves it in a disconnected state, but increasing the delay between the two service calls fixed this, and you may need to tweak this or some of the other delays.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like