Search code examples
windowscmdfilesystemsjunction

What is the reason for the obscure error in dir /al /s in command to report junctions -> file not found?


We have some code in C#:

RunProcessAndWaitForExit("cmd.exe", $"/C dir {pstrDriveLetter}:\\ /al /s > {pstrDriveLetter}:\\junctions.log");

In more simple terms its:

dir C:\ /al /s > D:\junctions.log

It is failing in some cases with:

2022-05-22 08:08:52 INFORMATION "Exception generated when running junction logger: cmd.exe finished with exit code = 1: Error: ERR: File Not Found
 Out: 

I'm really confused as what this could be:

I don't think it's doing a redirection to a file that doesn't exist as that fails with:

C:\repos\therepo [fix-dj-delete-snapshots ≡]> cmd.exe /c dir C:\ /al /s > B:\test.log
Out-File: Cannot find drive. A drive with the name 'B' does not exist.

What does this error mean? How can I fix it?


Solution

  • Okay I think this just means that it found no junctions!