Windows Internet Shortcuts (and can you add support for them!?)

It is not possible to open a Windows Internet Shortcut given as a parameter on the command line to Safari whether with or without the "-url" option.
Other browsers including IE do support this.
Whats more Safari does work with Internet Shortcuts dragged onto a tab (although it is believed that this is not a feature of the Browser but of the Operating System provided drag and drop support is enabled in the application one presumes).
Can this be fixed in a future version please?
An example of a Windows (VB)Script (.VBS) that works around the problem is given below (other Windows browsers effectively do this internally but Safari does not):
---BeginningOfScript---
function InternetShortcutURL(arg)
InternetShortcutURL = arg
dim ext
ext = Right(arg, 4)
if UCase(ext) = ".URL" then
dim fso
set fso = CreateObject("Scripting.FileSystemObject")
if (fso.FileExists(arg)) then
dim f
set f = fso.OpenTextFile(arg, 1)
dim lin
lin = ""
do
lin = f.ReadLine()
loop until UCase(Left(lin, 4)) = "URL=" or f.AtEndOfStream
if lin "" then
dim n
n = Len(lin)
if n >= 4 then InternetShortcutURL = Right(lin, n-4)
end if
f.Close()
end if
end if
end function

sub main()
dim cmd
cmd = "C:\Program Files\Safari\Safari.exe"
rem cmd = "C:\Program Files\Safari\Safari.exe -url"
rem WScript.Echo WScript.Arguments.Count
if WScript.Arguments.Count = 1 then
dim url
url = ""
dim arg
for each arg in WScript.Arguments
rem WScript.Echo arg
url = InternetShortcutURL(arg)
next
cmd = cmd & " " & url
end if
rem WScript.Echo cmd
set WshShell = CreateObject("WScript.Shell")
set oExec = WshShell.Exec(cmd)
end sub

main()
---EndOfScript---

Windows XP, Safari 3.1

Posted on Apr 13, 2008 11:49 AM

Reply
3 replies

Apr 13, 2008 1:06 PM in response to anonybuddy

Note after finding this old article (pre Safari for Windows) that suggests the .URL file format is suuported under Mac OS: http://www.macosxhints.com/article.php?story=20040111200114634
I tried adding and removing the new lines (dos2unix and unix2dos) (whilst verifiying the contents with notepad) and again with and without the Safari "-url" command line option.
I can only assume that if Safari for Mac OS/X supports the .URL file format (at least with the correct new line) that the Windows version of the code is broken....

Apr 13, 2008 1:15 PM in response to anonybuddy

Oh and BTW I stripped the [DEFAULT] and BASEURL= section stuiff out of the .URL file also so it was not an EXTENDED URL format but the original URL format. I haven't yet tested it with the Extended format again (although I probably did so the first time) but if it doesnt work with the basic version i've got no reason to expect it will work with the extended one (and I have little inclination to do so again)...

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Windows Internet Shortcuts (and can you add support for them!?)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.