I have a utility (myprog.exe) that requires a login an password to function. It has an .ini file for ID and Password , but for some reason it will not use the values I put in to the ini file (i think it is supposed to auto-update the ini file but that doesn't happen), so I'm trying to come up with a workaround.

If from a .bat file i run

echo <USER ID> | myappp.exe

this correctly passes the ID number to he program, and it advances to the PW input. If I type the PW and press [Enter], the program works correctly(image is the output of running the above command from batch file). All I want to do is pass this keyboard input for the PW on to the program . I've tried a few different syntax form for a 2nd echo command by they didn't work, or hang the program somehow.

I didn't write the utility, an the author is unable to offer further assistance.

dos output

Editing the batch file and adding a 2nd echo command

echo <password> | myappp.exe

in any syntax form, or trying to call a 2nd batch file after the first echo command

echo <USER ID> | myappp.exe
call 2ndinput.bat

all attempt have given the same result:

2nd input string result

  • Please edit your question and add the things you tried and what the result was. – LPChip Dec 19 '18 at 18:15
  • for formatting superuser ruins the formatting of code and various things, to prevent that you can highlight the code and then the brackets or quotes button.clicking one or the other formats it as code or as a quote, i've just edited your question and done it. I notice that superuser actually deleted where you wrote <user id> , which is really bad design from superuser/stackoverflow but anyhow.. When formatting it as code then it keeps it in. – barlop Dec 23 '18 at 4:24

The piping input to a command only works when the command prompts for keyboard input. (And even then not always e.g. it doesn't work for the 'runas' command)

You can use vbscript(bundled with win7), and its sendkeys function though. (Though bear in mind it's a bit limited in that it doesn't support unicode https://stackoverflow.com/questions/3198574/does-or-can-vbscripts-sendkeys-support-unicode ) But that limitation won't affect you. Note, C#'s sendkeys supports unicode.


Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set objArgs = Wscript.Arguments
dim a, b
arg1 = objArgs(0)
arg2 = objArgs(1)
WshShell.SendKeys "blahprogram " + arg1 + "{Enter}" + arg2 + "{Enter}"

So if you run blah.vbs abc def

it will run C:\>blahprogram abc<ENTER>def<ENTER>

You could make the sendkeys line

WshShell.SendKeys "blahprogram" + "{Enter}" + "123" + "{Enter}"

Then it will do


If you want to run

C:\>echo.| blahprogram<ENTER>123<ENTER>

You can use the line

WshShell.SendKeys "echo.|blahprogram" + "{Enter}" + "123" + "{Enter}"

So your whole program would be

Set WshShell = Wscript.CreateObject("Wscript.Shell")
Set objArgs = Wscript.Arguments
WshShell.SendKeys "echo.|blahprogram" + "{Enter}" + "123" + "{Enter}"
  • Where do I create the VBS script (?) – IRacing Muskoka Dec 19 '18 at 23:15
  • @IRacingMuskoka You open notepad (or whatever you would use to write a batch script), but instead of saving your file as blah.bat you save it as blah.vbs To run it you can try typing blah.vbs<ENTER> or you could do cscript blah.vbs<ENTER> or cscript //nologo blah.vbs<ENTER> – barlop Dec 20 '18 at 2:14
  • Maybe its late, but more likely I missed something. – IRacing Muskoka Dec 20 '18 at 6:37
  • I created the BLAH.VBS script (BETTERTPVBS.VBS) in the first part of your example. Just changed the name of blahprogram to bettertp I then modified my BETTERTP-VBS.BAT file to: bettertpvbs <UID#> <PW> When I run BETTERTP-VBS.BAT, The output of that was **E:\> bettertp-vps E:\> bettertp <UID> <PW> E:\> bettertp <UID> useage: bettertp [-h] [-v] [--test FILE_NAME] [--no-update] bettertp: error: unrecognized arguments: <UID#> E:\> <PW> '<PW>' is not recognized as an internal or external command, operable program or batch file. – IRacing Muskoka Dec 20 '18 at 6:50
  • Sorry, comment not letting me format the answer clearly... – IRacing Muskoka Dec 20 '18 at 6:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.