Page 1 of 1
File shortcut
Posted: Thu Apr 10, 2025 9:05 pm
by k3pto
Does PB have a way to access a file via a shortcut? FileSize (ShortcutName$) returns -1.
I tried searching the forum and did not find anything helpful.
Re: File shortcut
Posted: Thu Apr 10, 2025 9:22 pm
by AZJIO
Re: File shortcut
Posted: Sat Apr 12, 2025 11:43 am
by Axolotl
If I get you right, you have to search for these keywords.
Then you will find this one, among others.
Creating a desktop shortcut
Get the Shortcut target
Re: File shortcut
Posted: Sat Apr 12, 2025 1:09 pm
by BarryG
k3pto wrote: Thu Apr 10, 2025 9:05 pmFileSize (ShortcutName$) returns -1
You can't get the actual ".lnk" file itself with FileSize(), if that's what you mean. Well, I've never seen or found a way.
Re: File shortcut
Posted: Sat Apr 12, 2025 2:23 pm
by Marc56us
Hi,
A very old little program that I have wrote 11 years ago. (just updated)
Code: Select all
; Extract full program name from lnk file
; (C)Marc56(us) - 2015-11-27
; Updated 2025-04-12
RegEx.s = "^[A-Z]\:\\[\w\d\:\\\s\.()\-]+"
Source_Dir$ = GetUserDirectory(#PB_Directory_Desktop)
If Not CreateRegularExpression(1, RegEx)
Debug "Bad RegEx" : End
EndIf
If ExamineDirectory(0, Source_Dir$, "*.lnk")
While NextDirectoryEntry(0)
If DirectoryEntryType(0) = #PB_DirectoryEntry_File
File_Name$ = DirectoryEntryName(0)
If ReadFile(2, Source_Dir$ + File_Name$)
While Eof(2) = 0
Txt$ = ReadString(2)
If MatchRegularExpression(1, Txt$)
Debug "-" + RSet(File_Name$, 50, ".") + " > [" + Txt$ + "]"
EndIf
Wend
CloseFile(2)
EndIf
EndIf
Wend
FinishDirectory(0)
EndIf
Doesn't work in every situation, but almost.

Re: File shortcut
Posted: Sat Apr 12, 2025 2:58 pm
by AZJIO
BarryG wrote: Sat Apr 12, 2025 1:09 pm
k3pto wrote: Thu Apr 10, 2025 9:05 pmFileSize (ShortcutName$) returns -1
You can't get the actual ".lnk" file itself with FileSize(), if that's what you mean. Well, I've never seen or found a way.
He does not have a shortcut. He cannot get an executable file from the missing shortcut.