'Automating telnet process with batch file

Greetings stack community, I'm looking for a way to automate when I need to telnet.

This is the flow that I go through when I telnet:

-I open cmd and I telnet: Z:>telnet 10.01.02.12 300

-When I telnet to every IP the command propmt will ask for my user, once I input my user I need to press enter.

cmd screen clears

USER: I type my user

-Then cmd will ask for my password, then I enter the password and press enter.

PASSWORD: I type my password

-Once the password has been accepted, I'm required to enter 1 and press enter.

User & Password have been accepted, please enter 1:

I enter 1

Connection has been established.

Z:\

So I'm creating a .bat file which I can use to automate this, is there a way that I can pass the arguments of username, password, and the input of 1. ?

These is what I have so far in the .bat

@ECHO-OFF
ECHO Performing telnets
ECHO connecting to 10.01.02.12
telnet 10.01.02.12 300
ECHO connecting to 10.02.06.34
telnet 10.02.06.34 300
ECHO You have telnet to above IPs successfully.
PAUSE


Solution 1:[1]

How about a little bit of a compromise? Place the following lines at the top of your script (replacing UserName and Password with your info) and when you switch to each telnet window you should be able to do a CTRL+V to paste the answers to each question.

@ECHO OFF
(
    ECHO:UserName
    ECHO;Password
    ECHO;1
)|clip

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Darin