Reputation: 31
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.
Upvotes: 1
Views: 972
Reputation: 67216
You may try this:
(
echo SWAIN.dat
echo n
echo 1000
echo etc...
) | program.exe
Upvotes: 2
Reputation: 5197
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...
Upvotes: 2