Page 1 of 1

How to open program from a .lnk file ?

Posted: 30 Jan 2018 23:17
by Kucera
Hi,
should a program open when its .lnk shortcut is clicked in the list, or file open with its default?
Double clicking on a .lnk file, in the file window, I get a scripting window with an error about currents script being recursive, if I ignore, "A User-Defined Command (#1400) is not allowed to call itself." pops up.
My #1400 UDC is a script that puts "default or TextPad opens" in the first line of the "open with" menu

Have I missed a config setting after all those years, or is it some sort of a safety feature?
Could not find an yanswer by search, sorry.
Can someone put me out of my misery, please?
Thanks and regards Emil

Re: How to open program from a .lnk file ?

Posted: 30 Jan 2018 23:48
by highend
Mh?
My #1400 UDC is a script that puts "default or TextPad opens" in the first line of the "open with" menu
"Open with" items are populated via CFAs (Custom File Associations) so I have no clue how your script looks like or what
it is really supposed to do...

- To which item (with full path) does the .lnk refer to?
- Show your CFA definitions
- Show the UDC command with the full script

Re: How to open program from a .lnk file ?

Posted: 31 Jan 2018 00:35
by Kucera
highend wrote: - To which item (with full path) does the .lnk refer to?
- Show your CFA definitions
- Show the UDC command with the full script
It does not matter which path, any .lnk click gets a similar scripting window.
The script is ancient, donated many years ago by a kind member of this forum
Please see the zip for the definitions and the script.

Regards Emil
LNKproblem.zip

Re: How to open program from a .lnk file ?

Posted: 31 Jan 2018 02:08
by jupe
One way that should fix it for you is to just add the following as the top line in your CFA

Code: Select all

lnk>#

Re: How to open program from a .lnk file ?

Posted: 31 Jan 2018 04:55
by Kucera
jupe wrote:One way that should fix it for you is to just add the following as the top line in your CFA

Code: Select all

lnk>#
Thanks, that works fine for the .lnk shortcuts. Unfortunately it kills pretty much all the other CFAs if there are other files in the directory, I mean, the many choices for, say, a pdf file do not show in the CFA menu. Still, if there is no other way, it would solve my immediate problem, and for most of the time I can keep that line inactive.
For my edification - just how does that one line work?

Thanks and regards Emil

Re: How to open program from a .lnk file ?

Posted: 31 Jan 2018 05:21
by jupe
Kucera wrote:For my edification - just how does that one line work?
It redirects lnk files to the system default, bypassing your other CFA entries, it shouldn't have an effect on anything other than lnk files so if you are having problems with pdf etc, its strange.
Kucera wrote: I mean, the many choices for, say, a pdf file do not show in the CFA menu
Are you selecting a pdf file? it should be the same with and without the entry I suggested enabled, or are the lnk files linking to pdfs?

When you say there are missing entries what file type do you have selected?, or are you selecting a folder?

Re: How to open program from a .lnk file ?

Posted: 31 Jan 2018 05:31
by highend
One way to fix your script is:
Replace:

Code: Select all

		//Msg("Open $items in windows.<br>$verb", 1);
		#1053;
with:

Code: Select all

		//Msg("Open $items in windows.<br>$verb", 1);
		if ($ext LikeI "lnk") {
			$item = regexreplace($selItem, ';""$|"');
			$item = property("#LinkTarget", $item);
			if (exists($item) == 1) { run """$item"""; }
		} else {
			#1053;
		}

Re: How to open program from a .lnk file ?

Posted: 31 Jan 2018 06:12
by Kucera
jupe wrote: Are you selecting a pdf file? it should be the same with and without the entry I suggested enabled, or are the lnk files linking to pdfs?
When you say there are missing entries what file type do you have selected?, or are you selecting a folder?
You are right, it works the same checked or unchecked for normal files, just the .lnk files give limited choice or on double click open directly with their default program (see screenshots in the zip). That is plenty good for my needs. Thanks very much.

Regards Emil
linked vs real pdf.zip

Re: How to open program from a .lnk file ?

Posted: 31 Jan 2018 06:17
by Kucera
highend wrote:One way to fix your script is:
Replace:

Code: Select all

	with	
[code][/quote]

Thank you very much. I will try changing the script when I have some more time, for now the fix suggested by Jupe (see above msges) gives me what I need. 
This is one great forum!
Thanks again, guys.
Regards   Emil