I have a file admin.txt on pcloud server and my pc user name is admin.so i tried to get file admin.txt with following vscript.
Dim myURL
Dim password
Dim username
Dim strUserName
Set objShell = CreateObject("WScript.Shell")
Set wshShell = CreateObject("WScript.Shell")
strUserName = wshShell.ExpandEnvironmentStrings("%USERNAME%.txt")
WScript.Echo "User Name: " & strUserName
myURL = "https://webdav.pcloud.com/Public%20Folder/%USERNAME%.txt"
username = "[email protected]"
password = "xyz"
Dim HttpReq
Set HttpReq = CreateObject("MSXML2.XMLHTTP.3.0")
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 "D:/%USERNAME%.txt", 2 ' change your path here...
oStrm.Close
End If
ERROR MESSAGE:
line 16
char 1
Error: The parameter is incorrect.
code: 80070057
source: msxml3.dll
NOTE: On line
WScript.Echo "user name: " & strUserName
It shows my admin.txt name. But on line
myURL = "https://webdav.pcloud.com/public%20folder/%username%.txt"
It starts searching for %username%.txt
to download instead of admin.txt
which I want to download.
Problem resolved ,code Working as expected .