120

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?

8 Answers 8

135

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.

9
  • 4
    You may want to consider opening Powershell as an administrator
    – dotNetE
    Aug 27, 2013 at 22:57
  • 2
    You can also use get-childitem \\.\pipe\ Jan 22, 2015 at 22:15
  • 1
    @AndrewShepherd Interesting. What OS are you running on? It works for me on Windows Server 2012 and Windows 10 (PowerShell v3 and v5 respectively). Jan 23, 2015 at 1:10
  • 5
    On Windows 10 (20H2), somehow the get-childitem variant works on Powershell 5 but not Powershell 7. Dec 31, 2020 at 6:06
  • 2
    @Chih-HsuanYen - It's a bug. This is the workaround: [System.IO.Directory]::EnumerateFiles('\\.\pipe\')
    – Granger
    May 6, 2022 at 19:56
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.

3
  • 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 6, 2014 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 stackoverflow.com/questions/25109491/… Aug 4, 2014 at 20:26
  • 4
    Using pipelist.exe from SysInternals is even simpler, but it's command line only. Mar 4, 2018 at 2:29
57

Try the following instead:

String[] listOfPipes = System.IO.Directory.GetFiles(@"\\.\pipe\");
7
  • 7
    your missing a slash. string[] listOfPipes = System.IO.Directory.GetFiles(@"\\.\pipe\");
    – dmex
    Nov 25, 2010 at 23:15
  • I spent all night looking for a function to search for or list pipes. This is exactly what I needed. Thanks!! Apr 23, 2012 at 3:31
  • What is this special path? \\.\ seems to be used for raw access to a drive, but where does pipe come from? Mar 2, 2016 at 22:22
  • 2
    @Kevin "\\.\" means "this machine" as per msdn.microsoft.com/en-US/en-en/library/windows/desktop/… Apr 29, 2016 at 5:51
  • 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, 2016 at 10:28
51

Use pipelist.exe from Sysinternals.

1
  • 1
    See also handle.exe from sysinternals which will show almost all things that have an open handle.
    – JimR
    Jan 3, 2011 at 22:55
35

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.

5
  • Can you explain a bit more? Jan 5, 2017 at 15:06
  • 1
    This does list my pipes. Amazing! (note this will work because it works like a directory, as Andrew Shepherd's answer shows) Feb 7, 2017 at 19:55
  • I guess this is for debugging/diagnostics, since I noticed Chrome uses a lot of named pipes - I found 125 "chrome" pipes even when Chrome isn't running!
    – Cocowalla
    Jul 26, 2020 at 21:06
  • Works for Edge as well. I suspect it works with any browser.
    – Jay Elston
    May 26, 2022 at 19:08
  • Daynew, awesome! Thanks alot. @JayElston, doesn't work in Firefox :( Chrome only.
    – 1234ru
    Mar 8 at 22:05
25

At CMD prompt:

>ver

Microsoft Windows [Version 10.0.18362.476]

>dir \\.\pipe\\
2
  • 1
    Works on W10 but not on W7
    – cup
    Jan 10, 2020 at 10:06
  • 1
    Adding /b makes the output easier to deal with
    – ixe013
    Jan 3, 2022 at 16:34
19

C#:

String[] listOfPipes = System.IO.Directory.GetFiles(@"\\.\pipe\");
0
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.

1
  • 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, 2013 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.