So I have a simple JScript file, AKA MyScript.py
, that may be activated using two ways:
essentially double click the file.
AKA main.js
var strScript = ""; // read MyScript.js file to string
F = new Function(strScript)
(F)();
Is there a way to know, in MyScript.py
, how it was activated?
I'm looking for some solution similar to what's implemented in Python
if __name__ == "__main__":
It's not as portable as the Python method, but you could check the WScript.ScriptName property. When MyScript.js is launched directly, ScriptName
will return "MyScript.js". When it is included from main.js, the property will return "main.js".