-
-
Save mgeeky/2690755e2b12973af460c6c30fc83c83 to your computer and use it in GitHub Desktop.
Create ADODB.Stream object for HTA (mode IE9, IE10)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fso = new ActiveXObject("Scripting.FileSystemObject"); | |
var ado = (function() { | |
if (typeof window === "undefined") { | |
return new ActiveXObject("ADODB.Stream"); | |
} else { | |
var _GetObject = (typeof GetObject === "function") ? GetObject : (function() { | |
var script = window.document.createElement("script"); | |
script.setAttribute("language", "VBScript"); | |
script.innerHTML = "Function GetObjectHelper(name)\nSet GetObjectHelper = GetObject(name)\nEnd Function"; | |
window.document.body.appendChild(script); | |
return function(name) { | |
return GetObjectHelper(name); | |
} | |
})(); | |
try { | |
var temp = fso.BuildPath(fso.GetSpecialFolder(2), fso.GetTempName() + ".wsc"); | |
var otf = fso.OpenTextFile(temp, 2, true); | |
otf.Write('<?XML version="1.0"?><package><component id="activexHelper"><public><method name="_ActiveXObject"/></public><script language="JScript">function _ActiveXObject(name){return new ActiveXObject(name)}</script></component></package>'); | |
otf.Close(); | |
var obj = _GetObject("script:" + temp)._ActiveXObject("ADODB.Stream"); | |
fso.DeleteFile(temp, true); | |
} catch(err) { | |
throw new Error("Can not create ADOOB.Stream object."); | |
} | |
return obj; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment