c++batch-filenamed-pipes

Named Pipes with Command Prompt


Is it possible to pipe to a named pipe using the command prompt

dir >"\\.\pipe\my_named_pipe"

my_named_pipe being a pipe created by a win32 application

#include <windows.h>
#include <iostream>
int main()
{
HANDLE pipe= CreateNamedPipe("\\\\.\\pipe\\my_named_pipe",PIPE_ACCESS_INBOUND,PIPE_TYPE_BYTE,1,500,500,NMPWAIT_USE_DEFAULT_WAIT,NULL);

char* buf = new char[501];
ReadFile(pipe,buf,500,NULL);
std::cout << buf << std::endl;
}

Solution

  • I tried on windows XP

    dir >\\.\pipe\my_named_pipe
    

    and it worked properly.