1

I want to pass 3 seperate parameters into a cmd.exe program using a batch file. I have the following line of code that is able to call the program with the initial method:

@echo off
CMD /k ""C:\Users\user\Desktop\import\import.exe"" import -i   C:\Users\user\Desktop\testFolder\text.txt -d C:\Users\rsubedi\Desktop\testFolder
pause

this piece of code works great by calling the program with import -i C:\Users\user\Desktop\testFolder\text.txt -d C:\Users\rsubedi\Desktop\testFolder as the parameters.

Where i am Stuck:

Now i want to wait until the program is done then pass the username to the same program then wait for the program to verify the username then enter the password.

5
  • What is the problem with waiting until the program is done? It will return automatically once it's done... On the other hand, I'm not sure why you would put cmd /k into a batch file if you want it to return after the program has ended. Commented Jul 2, 2013 at 14:09
  • i don't want the program to quit, i want to wait for the program to finish doing one task, then i want to pass the username so that it can check to see if its valid, then wait until the program is done validating the username, then i want to pass in the password into the same program, which is why i have /k Commented Jul 2, 2013 at 14:31
  • Well, you can use echo to pipe input into the program, but you can't tell from within a batch file what the internal result from a function inside the program is (i.e. if the validation worked or not). You will need to split the program into two different programs if you want that. Commented Jul 2, 2013 at 14:36
  • I tried echo [email protected], but it did not seem to PIPE to the stdin Commented Jul 2, 2013 at 14:56
  • Hm, works for me when I try. Are you sure the program only uses stdin for its input? Commented Jul 2, 2013 at 19:10

1 Answer 1

1

try this:

C:\Users\user\Desktop\import\import.exe import -i   C:\Users\user\Desktop\testFolder\text.txt -d C:\Users\rsubedi\Desktop\testFolder

Remove the cmd /k command.

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

1 Comment

@echo off CMD /k ""C:\Users\user\Desktop\import\import.exe"" import -i C:\Users\user\Desktop\testFolder\text.txt -d C:\Users\rsubedi\Desktop\testFolder pause this code seems to work, but where i am stuck is passing the inputs into the cmd.exe program from the batch file after waiting a while. Please refer to Where i am Stuck section in the question

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.