View a list of symbolic links on system?

58

25

Is there a way to see a list of all the symbolic links that are active on a Windows machine?

Louis

Posted 2012-10-30T10:03:52.850

Reputation: 18 859

Answers

94

Try the following command:

dir /AL /S C:\
  • /A displays all files with a specific attribute, and L specifies reparse points (symlinks and directory junctions)
  • /S makes the command recursive
  • replace C:\ with the drive letter you want to scan, or with a path if you don't want to scan an entire drive

Indrek

Posted 2012-10-30T10:03:52.850

Reputation: 21 756

4Is there a way to make it not recurse into symlinks / junctions so that it doesn't get stuck in an infinite loop? – BrainSlugs83 – 2014-10-12T01:09:23.187

15

In PowerShell

Dir C:\ -Force -Recurse -ErrorAction 'silentlycontinue' | 
  Where { $_.Attributes -match "ReparsePoint"}
  • -Force includes hidden and system files
  • -Recurse gets all child items
  • -ErrorAction 'silentlycontinue' suppresses Access to the path XYZ is denied errors
  • Where { $_.Attributes -match "ReparsePoint"} checks folders and files if it's a junction

Explanation of Mode attributes:

  • d - Directory
  • a - Archive
  • r - Read-only
  • h - Hidden
  • s - System
  • l - Reparse point, symlink, etc.

nixda

Posted 2012-10-30T10:03:52.850

Reputation: 23 233

Thanks -- this could be really powerful for scripting -- is there a property that displays where the link goes to? -- it doesn't seem to be displayed by default, but if it's there we could script against it and that would be awesome. – BrainSlugs83 – 2014-10-12T01:11:29.393

1

@BrainSlugs83 To get the target of ReparsePoints programmatically , read this SO answer

– nixda – 2014-12-04T23:38:43.027

How to just get the ones create by the current user and not the OS? – boardtc – 2020-01-15T17:14:41.683

7

There's also a handy program for that called NTFSLinksView.

Edit: there's also SageLinks, this one checks the validity too.

colin lamarre

Posted 2012-10-30T10:03:52.850

Reputation: 171

1

I know this answer is late, but here's perhaps something closer to what you were probably looking for:

dir /AL /S C:\ | find "SYMLINK"

c D

Posted 2012-10-30T10:03:52.850

Reputation: 19

1Of course this will also show files and directories that have SYMLINK in their name. – Scott – 2018-09-25T00:38:55.250