3

Problem We have lots of not working .lnk files on a Windows Server 2016.

Example: Clicking on the shortcut 91205248__Orig.lnk causes the error:

Problem with shortcut - the drive or network ....

enter image description here

What I found out

  • The .lnk file can be edited in explorer
  • The stored path is correct "R:\my subfolders\Fallordner 2012\91205248"
  • After cutting out and saving the same path again the .lnk works
  • Size not working .lnk files: 15kb
  • Size working .lnk (after resaving): 2kb

Tracing with sysinternals procmon.exe

Working .lnk file:

enter image description here

Not working .lnk file:

enter image description here

Size changes after re-saving

15 kb = not working original

enter image description here

History

The system is migrated from Windows 2008 R2 file server / terminal server to server 2016 file server / terminal server

Questions

  • How can malformed .lnk files be recognized?
  • Is there any way to fix it (except manually opening and saving each .lnk file again)?

Edit
.lnk files are no text files, so simple search / replace operations won't work.

Edit2
I hesitate to perform a bulk operation and rewrite all paths in the .lnk files (as described here: Modify shortcut file (.lnk) target path using Powershell). So I hope there is somebody who faced a similar problem and solved successfully.

marsh-wiggle
  • 2,145
  • 5
  • 29
  • 45
  • Yes I can read ich (look at edit2). But shortcuts may contain more data than the path and I don't want to get in other trouble. – marsh-wiggle Nov 23 '18 at 07:27
  • There is exist a script to reset all shortcuts in a directory and used as `Total Commander` plugin: https://github.com/andry81/tacklebar It installs (`_install.bat`) a buttons bar and you enter a directory in a panel and run the links reset: `LINK->shell reset shortcut files in current directory (recursively)` – Andry Aug 04 '23 at 13:25

1 Answers1

0

.lnk files are just text files.

Open both the working and non-working lnk files in a text editor and see if there is a difference in the format.

If there is, use unix text tools to recursively change all the non-working files to match the format of the working files.

Jake Rankin
  • 129
  • 5
  • 1
    `.lnk files are just text files.` have you tried to open them in notepad? – marsh-wiggle Nov 22 '18 at 14:48
  • You shouldn't be using notepad anyway for a number of reasons, but ok, seems they are no longer just plain text files. A cursory google search revealed numerous tools that can alter them as well as instructions to do what you ask with powershell and vba script. So, look at past questions on this site dealing with powershell and lnk files, and make a simple script to read the targets in existing files and then write the same thing to a new lnk file in a different directory. You should be able to do them all at once... – Jake Rankin Nov 22 '18 at 15:33
  • .lnk files have a complex data structure and may contain fare more data then the target path. I don't want to loose this data while bulk fixing the path problem. So my first question is: how can a recongnize that a .lnk file does not work. Please share your experience. (btw. they haven't ever been txt files) – marsh-wiggle Nov 22 '18 at 16:07
  • I'm sure they were text files back in the day, maybe in Windows 9x? I thought I recall editing them manually in the past. What information do you need aside from icon and target in a shortcut? Powershell lets you read all the info and attributes from a lnk file and write a new one...that sounds like it would fit your needs? – Jake Rankin Nov 22 '18 at 20:28
  • 2
    lnks are txt files on FAT32 volumes, [because FAT32 doesn't know the concept of symlinks](https://en.wikipedia.org/wiki/Shortcut_(computing)#Microsoft_Windows). NTFS does. – Gerald Schneider Nov 23 '18 at 07:28