XMLDOM下載者生成器代碼(xmldown.hta)
來源:易賢網(wǎng) 閱讀:1159 次 日期:2014-08-12 16:46:21
溫馨提示:易賢網(wǎng)小編為您整理了“XMLDOM下載者生成器代碼(xmldown.hta)”,方便廣大網(wǎng)友查閱!

以下代碼保存成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("http://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("http://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>

更多信息請查看IT技術(shù)專欄

更多信息請查看腳本欄目
易賢網(wǎng)手機(jī)網(wǎng)站地址:XMLDOM下載者生成器代碼(xmldown.hta)
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

2025國考·省考課程試聽報名

  • 報班類型
  • 姓名
  • 手機(jī)號
  • 驗證碼
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 加入群交流 | 手機(jī)站點 | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網(wǎng)安備53010202001879號 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號
云南網(wǎng)警備案專用圖標(biāo)
聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號:hfpxwx
咨詢QQ:526150442(9:00—18:00)版權(quán)所有:易賢網(wǎng)
云南網(wǎng)警報警專用圖標(biāo)