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
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.
-
4
-
2
-
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
-
5On 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\')
– GrangerMay 6, 2022 at 19:56
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.
-
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)– CarlJul 6, 2014 at 21:56
-
2To 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
-
4Using
pipelist.exe
from SysInternals is even simpler, but it's command line only. Mar 4, 2018 at 2:29
Try the following instead:
String[] listOfPipes = System.IO.Directory.GetFiles(@"\\.\pipe\");
-
7your missing a slash. string[] listOfPipes = System.IO.Directory.GetFiles(@"\\.\pipe\");– dmexNov 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
-
5We 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 BokNov 23, 2016 at 10:28
Use pipelist.exe from Sysinternals.
-
1See also handle.exe from sysinternals which will show almost all things that have an open handle.– JimRJan 3, 2011 at 22:55
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.
-
-
1This 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! Jul 26, 2020 at 21:06
-
-
Daynew, awesome! Thanks alot. @JayElston, doesn't work in Firefox :( Chrome only.– 1234ruMar 8 at 22:05
At CMD
prompt:
>ver
Microsoft Windows [Version 10.0.18362.476]
>dir \\.\pipe\\
-
1
-
1
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.
-
1The 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.– dss539Jul 30, 2013 at 14:13