0

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

http://i.stack.imgur.com/puvRZ.png

  • 2
    You won't be able to do this with just a batch script, but all the same, we are not a scripting service. So provide us with what you have attempted so far – Ramhound May 16 '16 at 21:58
  • 2
    If your router supports telnet, you can google an already written script. – Divin3 May 16 '16 at 22:37
  • You are probably after a program like "CURL" which can do web requests). Visit stackoverflow.com/questions/2710748/… – davidgo May 16 '16 at 23:10
  • I have exactly the same requirement, but so far the only way I have found to do it is with a script for the Selenium add-on for Firefox. Unfortunately, the TP-Link router does not use form fields, so I have not found a way to get get curl to log in. @Divin3 suggests an approach that I hadn't considered, so I'll investigate and let you know. I have found that my TD-W9980 does support Telnet, and it looks promising. – AFH May 16 '16 at 23:12
  • I haven't found how to do the disconnect, but I can reboot. I will use this only if desperate, as it interrupts any current intranet activity. – AFH May 17 '16 at 16:22
0

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

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.