1

So there is a program someone wrote (that I don't have access to) that was written in C#, in which when I open it, it brings up a command prompt, asks several questions, and then returns an output.

What I want to do it write a batch file to automate entering all the arguments manually but nothing has really worked for me thus far. I tried "program.exe arg1 arg2.." in the command prompt and reading about the windows commands (I checked out ss64) but nothing seems to work.

So to summarize what happens is:

1) I open the program (a .exe file) in the command prompt (or click on it) where it asks me to enter a value or filename https://i.sstatic.net/bZsSi.png

2) I press enter to continue to the next question and the command asks me to answer another question (unless I finished the last one, in which case the program finishes executing and then closes). https://i.sstatic.net/nqJ5M.png

Now, how would I go about making a batch file that enters SWAIN.dat, n, 1000, etc... automatically into this program? Again, I don't have access to the original program. i only know it was written in C#.

Thank you very much.

4
  • Here is an example of the "program.exe arg1 arg2.." approach i.sstatic.net/RsHWV.png Commented Jan 28, 2014 at 23:17
  • The program clearly doesn't take arguments, and is just ignoring anything you parse to it. You could write a VB script and use send keys - take a look at this. Commented Jan 28, 2014 at 23:32
  • I've posted an example for you. Commented Jan 28, 2014 at 23:35
  • 1
    Try program.exe < data.txt where data.txt is a file containing your answers. Commented Jan 29, 2014 at 0:03

2 Answers 2

2

You could create a VB script -

set WshShell = WScript.CreateObject("WScript.Shell") 
WshShell.Run "cmd" 
WScript.Sleep 100 
WshShell.AppActivate "C:\Windows\system32\cmd.exe" 
WScript.Sleep 100 
WshShell.SendKeys "program.exe{ENTER}" 
WScript.Sleep 100 
WshShell.SendKeys "SWAIN.dat{ENTER}" 
WScript.Sleep 100
WshShell.SendKeys "1000{ENTER}"

etc...

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

Comments

2

You may try this:

(
echo SWAIN.dat
echo n
echo 1000
echo etc...
) | program.exe

1 Comment

Program cannot start or run due to being incompatible with 64 bit Windows (which is weird because it runs well when I enter everything manually). I'll try it on another machine see how it goes.

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.