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.
I've been wanting to implement this function for some time now. I haven't got around to it, until now!
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;
}