What is the full path of this script? ECMAScript equivalent to %~f0

Solution for What is the full path of this script? ECMAScript equivalent to %~f0
is Given Below:

This got me stumped.

In a (Windows) batch file I can file the name of the file and path of said batch file with:

SET thisfile=%~f0
ECHO thisfile

C:UsersGwenStefani>C:projectsscriptsthis_file.bat

However, I want to do this is Photoshop. I can find the name of the current document with:

var myPath = app.activeDocument.path;
var myDoc = myPath + "/" + app.activeDocument.name;
alert(myDoc);

…But the file path (and name) of the script that’s just be called – I’m all out of ideas.
Anyone?

After a let more digging, I found what you after, recorded here for my future self:

var myScript = $.fileName;
alert(myScript);

/c/somefolder/gwen/stefani/myscript.jsx