How to use Excel VBA Telnet To Autorun Commands?

Excel VBA Telnet Client for Remote Connect

We use Telnet Client sessions to control or manage systems that does not have a keyboard or monitor attached to it.

A simple example is the Internet Broadband Router at our home. Similar to that there are lot of network routers, bridges and servers which has to be connected through a Telnet session and operate them.

Network Technicians connect to these devices from remote computer and resolve if there are any issues. Usually these servers will be Unix or Linux based and the commands that you can issue here are some of the basic Unix Commands.

Also Read: Make your Excel Talk

Telnet Commands from Command Prompt

If you have a broadband router at your home, you can try to connect to it with below steps.

  1. Open a Command Prompt.
  2. Type ‘Telnet 192.168.1.1’ or ‘Telnet 10.0.0.1’
  3. Login with user id ‘admin’ and password as ‘password’ or ‘admin’
  4. Type ‘ps’. This command will show the running processes in the router.
  5. Type ‘help’ to get a list of supported commands.

Also Read: Login to Facebook, Twitter, Google+ in IE from Excel

How to VBA Telnet from Excel?

When a set of Telnet commands need to be executed on a remote device or server through telnet client session, then this Excel VBA macro code can be used to automate the telnet session.

Download a Sample Excel VBA Telnet Session Downloaded 2,791 Times

This code tried to connect to Telnet server with IP 192.168.1.1. Replace this Server IP address with your Server details and other login credentials. Winsock component will be used to execute this Telnet session.

The above code waits for certain time interval (1 second to 5 Seconds) for different operations. Based on the speed of your server, modify this ‘wait time’.

This code, not only issue telnet commands to server, but also read data or messages returned by Telnet server or device. This way we can add more automation option by processing the return message and perform different operations accordingly.

More Tips: How to get Folders List and Size

  • Fuko

    Anyway to get this to work for Windows 7

    • https://officetricks.com/ kumarapush

      Is it not working in Windows 7?
      Please try this in Windows 7 and post the error message or difficulties, that you are facing.

      • Fuko

        I have tried in Windows 7 and Windows 10 and I have copied in the MSWinsock.ocx and tried to use it however I get a license error when i try to reference it

        • https://officetricks.com/ kumarapush

          #1: I guess it is problem with MSWinsock.ocx installation. After copying the ocx file did you try to register it? please check whether OCX is working fine with any other applications.
          #2: Is this Code working fine with Windows 7?

  • Lord Lizarazo

    Hello,What is the macro passowrd?

  • De ZuyNgan

    I need vbaproject password, many thanks.

  • Cleiton Brandão Oppenheimer

    Hi, The Excel file is not working in my Microsoft Office 2013. WOuld you please help me?

  • jump jack

    why making the excel file available for download if its macros are password protected?
    Does it contain a virus?

    • Aaron

      I agree and when I run the file I get a compile error in hidden module: Module1

  • Aaron

    I have Office 2010 but it doesn’t like MSWinsockLib, any ideas?