windowscmdevernote

Faking standard input on the Windows command line


I want to use Evernote's ENScript.exe to create new notes, entering the text and title as arguments. The problem is that ENScript only allows the text to be entered via a file or via standard input.

For my current workaround I use a .bat file to write the argument to a file, then call ENScript with the /s argument pointing to the file to read it in, but that forces the default title to the temporary file's filename (a behavior I do not want).

So my question is: Is there a way to "fake" standard input on the Windows command line so that I can use an argument (passed from another program) to generate the note text? The beginnings of the script would be something like

ENScript.exe createNote /i %1

with the standard input following.


Solution

  • 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"