Download file from webdav server

668 Views Asked by At

My VBScript is as follows:

Dim myURL 
Dim password
Dim username 
myURL = "https://webdav.pcloud.com/Public%20Folder/d.txt" ' change your URL here...
username = "[email protected]"
password = "xyzpassword"

Dim HttpReq 
Set HttpReq = CreateObject("Microsoft.XMLHTTP")
HttpReq.Open "GET", myURL, False, "username", "password"
HttpReq.send
myURL = HttpReq.responseBody
If HttpReq.Status = 200 Then
    Set oStrm = CreateObject("ADODB.Stream")
    oStrm.Open
    oStrm.Type = 1
    oStrm.Write HttpReq.responseBody
    oStrm.SaveToFile "C:\d.txt", 2 ' change your path here...
    oStrm.Close
End If

There is no error detected when I run it but the file is not downloaded on to my PC.

1

There are 1 best solutions below

0
rohit7373 On

remove " from username and password.

Dim myURL 
Dim password
Dim username 
myURL = "https://webdav.pcloud.com/Public%20Folder/d.txt" ' change your URL here...
username = "[email protected]"
password = "xyzpassword"

Dim HttpReq 
Set HttpReq = CreateObject("Microsoft.XMLHTTP")
HttpReq.Open "GET", myURL, False, username, password
HttpReq.send
myURL = HttpReq.responseBody
If HttpReq.Status = 200 Then
    Set oStrm = CreateObject("ADODB.Stream")
    oStrm.Open
    oStrm.Type = 1
    oStrm.Write HttpReq.responseBody
    oStrm.SaveToFile "C:\d.txt", 2 ' change your path here...
    oStrm.Close
End If