javac#node.jswindowsshortcut-file

Why are windows shortcut not accessible when reading the directory


Recently I tried to write a small application to help me sort the shortcut on my desktop.

I quickly noticed that the shortcuts (.lnk, .url) created by the system or an application ( an installer, the steam "create shortcut" function, etc) did not appear in the list of processed files.

Thinking that the problem came from Java, I also made the test in C#, Dart and NodeJS and each time the same result: the shortcuts created with the function "Create a shortcut" of the right click menu are well seen and processed by my program, the shortcuts created by the system are ignored and absent from the listings.

Do the shortcuts created by the system have a different "marking" from an authorization point of view? Is there a way to be able to process them?

I attach my NodeJS test code, if needed I could share the other code. I also specify that all my tests were carried out with Windows 10 Pro 1909 (18363.657) on an Administrator account.

const fs = require("fs");
const os = require('os');
const path = require('path');

var desktopPath = fs.readdirSync(`${os.homedir()}${path.sep}Desktop`);

for(var i = 0; i < desktopPath.length; i++) {
    console.log(desktopPath[i]);
}

Thanks for your attention.


Solution

  • The desktop that you see is a combination of multiple desktop folders.

    C:\Users\{username}\Desktop
    C:\Users\Public\Desktop
    …
    

    Do a right-click properties to see where the link is stored.