diff --git a/app.js b/app.js index c28e9d9..38e8b78 100644 --- a/app.js +++ b/app.js @@ -187,6 +187,17 @@ if (typeof CreateObject === "undefined") { }; } +if (typeof UseObject === "undefined") { + var UseObject = function(progId, callback) { + var obj = CreateObject(progId); + try { + return callback(obj); + } finally { + obj = null; + } + } +} + /** * @FN {string} The name of the file. */ @@ -283,7 +294,9 @@ function require(pathname) { return filename; })({ existsSync: function(filename) { - return CreateObject("Scripting.FileSystemObject").FileExists(filename); + return UseObject("Scripting.FileSystemObject", function(fso) { + return fso.FileExists(filename); + }); } }, { join: function() {