3

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;
}
Samuel
  • 1,073
  • 11
  • 22
  • 5
    This seems like something that's open to fairly trivial testing. – Jerry Coffin Oct 14 '13 at 22:18
  • And if it's not possible, it would be fairly easy to write a small utility that takes `stdin` and sends it to a named pipe. – Mats Petersson Oct 14 '13 at 22:33
  • Note `>` is not piping, is redirection! `|` is what should be used. – LS_ᴅᴇᴠ Oct 15 '13 at 08:20
  • Does this answer your question? [Is it possible to open a named pipe with command line in windows?](https://stackoverflow.com/questions/3670039/is-it-possible-to-open-a-named-pipe-with-command-line-in-windows) – phuclv Jul 11 '23 at 06:52

2 Answers2

6

I tried on windows XP

dir >\\.\pipe\my_named_pipe

and it worked properly.

Samuel
  • 1,073
  • 11
  • 22
  • 2
    Looks like this does not work in windows 10? I tried to type `dir > \\.\pipe\my_named_pipe` and the result is `The system cannot find the path specified.` – Trung0246 Oct 05 '21 at 08:51
-1

According to Wikipedia http://en.wikipedia.org/wiki/Named_pipe the answer is no for Windows and yes for Unix. But Windows can run Unix so it depends if you want to run Unix Services. See for more info http://en.wikipedia.org/wiki/Windows_Services_for_UNIX

David Candy
  • 735
  • 5
  • 8