Insert an input to an exe automatically by Command Window

조회 수: 9 (최근 30일)
Matteo Volpi
Matteo Volpi 2021년 5월 11일
답변: Jan 2021년 5월 11일
Good morning,
I have to launch a executable file.
I use:
dos('executable.exe')
After that, the exe reports on the Command Window a string which ask me to type an input.
At the moment I should do it time after time.
I tried:
dos('executable.exe < file.txt')
but it doesn't work.
It could be due to the fact that the input file is indicated after the launch of the exe file and not contextually
  댓글 수: 3
Matteo Volpi
Matteo Volpi 2021년 5월 11일
Thank you for your reply.
I cannot moidfy my exe,
I think you are suggesting this approach
dos('executable.exe file.txt')
The problem is not solved. The executable writes a prompt in the Command Window and waits for me to enter the file name from the keyboard.
My question was looking for a Matlab solution where this operation could be automated.
Rik
Rik 2021년 5월 11일
The exe must allow such a thing. Matlab cannot send keystrokes to arbitrary programs.

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2021년 5월 11일
The function must wait until the corresponding strings appear in the command window, which can be caught by: https://www.mathworks.com/matlabcentral/fileexchange/32005-cmdwintool
But the code must run, during the external program blocks the execution. I assume a timer callback can solve this. But I'd never try this, because this sounds like a programming technique, which is far too complex to be reliable.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by