Faking standard input on the Windows command line

一笑奈何 提交于 2019-11-30 19:33:55

You are looking for a pipe operation that captures the output of one command and sends it as input to the next. This is a standard capability in most operating systems.

The pipe symbol for Windows CMD is |

Your script could be as simple as:

@echo %~2|@ENScript.exe createNote /i %1

If your script is called MakeNote.bat, you would call it like

MakeNote "your title" "This is the text of your note"

One can "fake" standard input by using redirection:

command args... < filename args...

where the < means input redirection ("read standard input from the filename after the < instead of the terminal").

(Note that old Windows or DOS programs may read straight from the terminal, making input redirection useless; this hopefully won't apply to something as recent as Evernote.)

For your example:

ENScript.exe < "%1"

Feel free to add more arguments before or after the redirection. For example, if your script will be called as script filename title, you will want to invoke ENScript /i "%2" < "%1".

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!