Perhaps someone will find it useful. It worked both times I tested it. (Will your results vary?)
Here's the script ...
on open dropList
if (count items of dropList) > 1 then
beep
delay 1
return
end if
set applAlias to (item 1 of dropList) as alias
tell application "Finder"
if (class of item applAlias) is not application file then
beep
delay 1
return
end if
end tell
my addApplDock(applAlias)
end open -------------------------------------
on addApplDock(applAlias)
-- 1 construct the |file-data| record
set applPath to (POSIX path of applAlias)
if (last character of applPath) = "/" then
set applPath to (text 1 thru -2 of applPath)
end if
set newFileData to {|_CFURLString|:applPath, |_CFURLStringType|:0}
--2 construct the |tile-data| record
tell application "Finder" to name of applAlias
set newTileData to {|file-data|:newFileData, |file-label|:the result, |file-type|:2, showas:3}
-- 3 construct the newApplicationItem record
set newApplicationItem to {|tile-data|:newTileData, |tile-type|:"file-tile"}
-- 4 write to Dock preference file
set prefsFile to (((path to preferences from user domain) as text) & "com.apple.dock.plist") as alias
tell application "System Events"
set dockPath to (prefsFile as text)
set dockRec to (value of property list file dockPath)
set |persistent-apps| of dockRec to ((|persistent-apps| of dockRec) & {newApplicationItem})
set (value of property list file dockPath) to dockRec
end tell
tell application "Dock" to quit
end addApplDock ------------------------------