Error while trying to write inputs to running console app with a batch

前端 未结 1 1254
既然无缘
既然无缘 2021-01-26 07:15

I have an exe file that I want to execute with a batch file.

Exe file is a third party console app that will prompt for input three times.

So I want to fill it in

1条回答
  •  深忆病人
    2021-01-26 07:32

    Your config.exe does not accept redirection at all. It requires real console buffers.

    1. If you want to automate it, you could create another console application which will
    • start your config.exe using CreateProcessW
    • write your lines to STD_INPUT_HANDLE using WriteFile (ASCII, \n separated lines) or WriteConsoleInputW (if you need unicode characters)
    • after write is complete, just wait for config.exe termination and return exit code
    1. Another simpler option is ConEmu terminal (I'm the author). There is GuiMacro scripting which could be easily used from console. So you could just run from your prompt or wrap in in batch file (run in ConEmu):

      ConEmuC.exe -GuiMacro print "\nsomeText\nsome Other Text\n" & config.exe remove

    0 讨论(0)
提交回复
热议问题