Use target of URL shortcut with external command

I'm trying to utilize the Events of the URL File Type to open URL shortcuts in a different browser. For example, links double-clicked on go to Firefox, while links double-clicked on while holding down the Alt key go to Edge.

I cannot figure out how to pass the target URL to the external program. I tried {target} but that does not get resolved.

Any ideas or suggestions?

I've been wanting to implement this function for some time now. I haven't got around to it, until now! :grinning:

You'll need to provide the path to your browser in the browser variable. Be sure to escape the slashes with another (\\).
It supports the selection and opening of multiple *.url files. This was written quickly so if you run into any problems with script I will address them later. Although I tested and works without problems as far as I can tell.

function OnClick(data)
{
	var browser = "C:\\path\\to\\browser.exe"
	var fso = new ActiveXObject("Scripting.FileSystemObject");
	var src = data.func.sourcetab;
	var cmd = data.func.command;
	cmd.deselect = false;

	for (var i = 0; i < src.selstats.selitems; i++)
	{
		if (src.selected(i).ext != ".url") continue;
		var file = fso.OpenTextFile(src.selected(i), 1, false);
		var re = new RegExp("URL=(.*)");
		
		while (!file.AtEndOfStream)
		{
			var line = file.ReadLine();
			var match = String(line).match(re);
			if (match)
			{
				cmd.RunCommand(browser + ' ' + match[1]);
				break;
			}
		}
		file.Close();
	}
	delete re, fso;
}

Firefox will accept the .url file directly. Edge and Chrome want the string (item.metadata.other.target), ideally with % doubled.

There's a Chrome extension which apparently makes it work: