Javascript 获取当前运行脚本文件所在的目录
DirectoryUtility = { // function getCurrentDirectory: returns currentDirectory path // with a trailing backslash. getCurrentDirectory : function ( ) { var scriptFullName = WScript.ScriptFullName; var scriptName = WScript.ScriptName; return scriptFullName.substr ( 0, scriptFullName.lastIndexOf ( scriptName ) ); } } /* 用法 */ DirectoryUtility.getCurrentDirectory ( );