0

I'm trying to write an login batch script. I'm having an execuable a.exe and I want to automatically do the login:

if u do it manually it looks like:

a.exe param1 param2
a>login Random-Name
a>Username: "put in username + pressENTER"
a>Password: "put in password+ press ENTER"
a>quit

So and this whole thing it want to do by a batch script

init.bat username password

@echo off 
START a.exe login srv_name
%1
%2

Not sure how to accomplish that, I tried a few thinks now but I wasnt even able to echo the Username after a>Username: . Thanks for any help.

2
  • Quite odd that the console program you are using does not accept command line arguments. Commented Nov 18, 2016 at 17:36
  • typo, just fogot :) Commented Nov 22, 2016 at 12:50

1 Answer 1

1

I can't test this right now but try:

echo login srv_name > temporary_file
echo %1 >> temporary_file
echo %2 >> temporary_file
type temporary_file | a.exe

If you omit the last line you will see that a file named temporary_file will be created in your current directory. It should contain what user would normally input manually while interacting with a.exe.

Last line feeds contents of this file to the program. Be aware though, that not all programs will accept redirected input.

Also you should look at documentation of your program, because many do provide a dedicated way to interact with them from within a script.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.