117

Is there an easy way to test whether your named pipe is working correctly? I want to make sure that the data I'm sending from my app is actually being sent. Is there a quick and easy way to get a list of all the named pipes?

Doug T.
  • 64,223
  • 27
  • 138
  • 202

8 Answers8

131

In the Windows Powershell console, type

[System.IO.Directory]::GetFiles("\\.\\pipe\\")

If your OS version is greater than Windows 7, you can also type
get-childitem \\.\pipe\

This returns a list of objects. If you want the name only:

(get-childitem \\.\pipe\).FullName

In Powershell 7, the second example \\.\pipe\ does not work (see this known bug), so you will have to stick to the first syntax.

Andrew Shepherd
  • 44,254
  • 30
  • 139
  • 205
119

You can view these with Process Explorer from sysinternals. Use the "Find -> Find Handle or DLL..." option and enter the pattern "\Device\NamedPipe\". It will show you which processes have which pipes open.

goertzenator
  • 1,960
  • 18
  • 28
Rob Walker
  • 46,588
  • 15
  • 99
  • 136
  • Check which version of Process Explorer you have before you try this. It does not work on v15.23, but works on v16.02. (haven't tried other versions) – Carl Jul 06 '14 at 21:56
  • 2
    To avoid possible exceptions - as it is mentioned in other answers - you can use my solution which is more low level but working like a charm even if named pipe's name contains invalid characters in way of name of file. Please see http://stackoverflow.com/questions/25109491/how-can-i-get-a-list-of-all-open-named-pipes-in-windows-and-avoiding-possible-ex/25126943#25126943 – user2126375 Aug 04 '14 at 20:26
  • 4
    Using `pipelist.exe` from SysInternals is even simpler, but it's command line only. – Chris Charabaruk Mar 04 '18 at 02:29
57

Try the following instead:

String[] listOfPipes = System.IO.Directory.GetFiles(@"\\.\pipe\");
porges
  • 30,133
  • 4
  • 83
  • 114
Vincent Lidou
  • 641
  • 6
  • 2
  • 7
    your missing a slash. string[] listOfPipes = System.IO.Directory.GetFiles(@"\\.\pipe\"); – dmex Nov 25 '10 at 23:15
  • I spent all night looking for a function to search for or list pipes. This is exactly what I needed. Thanks!! – MushroomSoda Apr 23 '12 at 03:31
  • What is this special path? \\.\ seems to be used for raw access to a drive, but where does `pipe` come from? – Kevin Doyon Mar 02 '16 at 22:22
  • 2
    @Kevin "\\.\" means "this machine" as per https://msdn.microsoft.com/en-US/en-en/library/windows/desktop/aa365783(v=vs.85).aspx – Eugene Ryabtsev Apr 29 '16 at 05:51
  • The best thing is, that also works in Powershell... `[System.IO.Directory]::GetFiles("\\.\pipe")` Thanks! – Poorkenny Sep 05 '16 at 15:27
  • 5
    We have had issues with this method working on windows 10 - getting error "Second path fragment must not be a drive or UNC name. Parameter name: path2 " – Dai Bok Nov 23 '16 at 10:28
  • @DaiBok This is handled [here at SO](https://stackoverflow.com/q/25109491/806690). – tm1 Nov 22 '18 at 14:09
50

Use pipelist.exe from Sysinternals.

Jader Dias
  • 88,211
  • 155
  • 421
  • 625
Jay
  • 501
  • 4
  • 2
  • 1
    See also handle.exe from sysinternals which will show almost all things that have an open handle. – JimR Jan 03 '11 at 22:55
34

I stumbled across a feature in Chrome that will list out all open named pipes by navigating to "file://.//pipe//"

Since I can't seem to find any reference to this and it has been very helpful to me, I thought I might share.

Daynew
  • 461
  • 4
  • 5
23

At CMD prompt:

>ver

Microsoft Windows [Version 10.0.18362.476]

>dir \\.\pipe\\
19

C#:

String[] listOfPipes = System.IO.Directory.GetFiles(@"\\.\pipe\");
porges
  • 30,133
  • 4
  • 83
  • 114
Omar Elsherif
  • 259
  • 2
  • 2
10

The second pipe was interpreted by this web site when submitted... You need two backslashes at the beginning. So make sure to use System.IO.Directory.GetFiles(@"\\.\pipe\").

Note that I have seen this function call throw an 'illegal characters in path.' exception when one of the pipes on my machine had invalid characters. PipleList.exe worked ok though, so it seems like a bug in MS's .NET code.

riQQ
  • 9,878
  • 7
  • 49
  • 66
Vincent Lidou
  • 101
  • 1
  • 2
  • 1
    The note about 'illegal characters in path' is an important point, because it is very common for programs to open pipe names that trigger this. Any program that opens a pipe named like `C:\myLocation\someFile.x` will cause this error. – dss539 Jul 30 '13 at 14:13