基于this question我希望从互联网下载文件并在下载后执行此文件。
下面有这个代码,但没有任何反应。为什么呢?
有人也有这个麻烦吗?
PS:我正在使用 IE 11
<HTML>
<HEAD>
<script type="text/vbscript" language=vbscript>
sub test
strFileURL = "http://www.therealbest.com/files/rosa.jpg"
strHDLocation = "C:\shutterstock_242521867.jpg"
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
objXMLHTTP.open "GET", strFileURL, false
objXMLHTTP.send()
If objXMLHTTP.Status = 200 Then
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1
objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0
Set objFSO = Createobject("Scripting.FileSystemObject")
If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
Set objFSO = Nothing
objADOStream.SaveToFile strHDLocation
objADOStream.Close
Set objADOStream = Nothing
End if
Set objXMLHTTP = Nothing
Set WshShell = CreateObject("WScript.Shell")
WshShell.Run strHDLocation
Set WshShell = Nothing
end sub
</script>
</HEAD>
<BODY OnLoad="vbscript:test">
these are the instructions
<button onclick="vbscript:test" >Run the script</button>
</BODY>
</HTML>
感谢您的帮助。