JScript which

Author Johnny Josefsson on November 19, 2010 | Print | Bookmark
function which(filenameToFind) { 
 filenameToFind = FormatArguments(arguments); 
 if( exists(filenameToFind) ) 
 return filenameToFind; 
 
 if (!/\.\s*/.exec(filenameToFind)) { 
 for (var e in exts = (".js;"+$PATHEXT).split(";")) { 
 result = which(filenameToFind + exts[e]); 
 if (!IsNullOrEmpty(result)) 
 return result; 
 } 
 } 
 
 for (var each in paths = (".;" + $PATH).split(";")) { 
 var testPath = $$.fso.BuildPath(paths[each], filenameToFind); 
 if (exists(testPath)) { 
 return $$.fso.GetAbsolutePathName(testPath); 
 } 
 } 
 
 return ""; 
}

Was this article helpful?

Yes No

Category: Scripting, JScript

Last updated on August 12, 2012 with 949 views