Hi !
I am trying to test a download of a mp3 file from this URL:
but I encounter an Access Denied error at line No. 26, knowing that the url works in all browsers?
Can anyone here tell me what's my mistake ?
I am trying to test a download of a mp3 file from this URL:
Code:
[URL unfurl="true"]http://promodj.com/download/4126268/Chris%20Parker%20-%20Life%20MIX%20%282011%20-%202013%29%20%28promodj.com%29.mp3[/URL]
Can anyone here tell me what's my mistake ?
Code:
Option Explicit
Dim Titre,objFSO,Ws,objXMLHTTP,PathScript,Tab,URL,strHDLocation,objADOStream,Command,Start,File,ExempleURL
Titre = "Downloading MP3 by © Hackoo 2013"
Set objFSO = Createobject("Scripting.FileSystemObject")
PathScript = objFSO.GetParentFolderName(wscript.ScriptFullName) 'Chemin ou se localise le Vbscript
Set Ws = CreateObject("wscript.Shell")
ExempleURL = "[URL unfurl="true"]http://promodj.com/download/4126268/Chris%20Parker%20-%20Life%20MIX%20%282011%20-%202013%29%20%28promodj.com%29.mp3"[/URL]
URL = InputBox("Tapez ou collez l'URL dans le champ de saisie Exemple : "&Dblquote(ExempleURL)&"",Titre,ExempleURL)
URL = Escape(URL)
msgBox URL
If URL = "" Then WScript.Quit
Tab = split(url,"/")
File = Replace(Tab(UBound(Tab)),"28","")
File = Replace(Tab(UBound(Tab)),"29","")
File = Replace(Tab(UBound(Tab)),"20","")
File = Replace(Tab(UBound(Tab))," ","_")
File = Replace(Tab(UBound(Tab)),"-","_")
File = Replace(Tab(UBound(Tab)),"(","_")
File = Replace(Tab(UBound(Tab)),")","_")
File = Replace(Tab(UBound(Tab)),"%","_")
Msgbox "The download of " & Dblquote(File) & " is in progress ! ",64,"The download of " & Dblquote(File) & " is in progress ! "
strHDLocation = PathScript & "\" & File
Set Ws = CreateObject("WScript.Shell")
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
objXMLHTTP.open "GET",UnEscape(URL),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
If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
objADOStream.SaveToFile strHDLocation
objADOStream.Close
Set objADOStream = Nothing
End If
Set objXMLHTTP = Nothing
MsgBox "The Download of " & Dblquote(Tab(UBound(Tab))) & " is finished ! ",64,"The Download of " & Dblquote(Tab(UBound(Tab))) & " is finished ! "
Command = "Cmd /c start explorer "& Dblquote(strHDLocation) &" "
Start = Ws.Run(Command,0,False)
Function Dblquote(str)
Dblquote = chr(34) & str & chr(34)
End Function