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

Issue

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!

Answered By – Nick

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published