Skip to content

Instantly share code, notes, and snippets.

@lyonsun
Last active August 29, 2015 14:02
Show Gist options
  • Select an option

  • Save lyonsun/cda807ad2dd949610dc6 to your computer and use it in GitHub Desktop.

Select an option

Save lyonsun/cda807ad2dd949610dc6 to your computer and use it in GitHub Desktop.
a basic vbs script to accomplish HTTP POST
'URL to open....
sUrl = "http://example.com"
'POST Request to send.
sRequest = "post=true"
sDestFolder = "C:/"
sImageFile = "example" & "_" & Year(Date) & "_" & Month(Date) & "_" & Day(Date) & ".log"
WScript.Echo "Done..."
HTTPPost sUrl, sRequest
Function HTTPPost(sUrl, sRequest)
set oHTTP = CreateObject("Microsoft.XMLHTTP")
oHTTP.open "POST", sUrl, false
oHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
oHTTP.setRequestHeader "Content-Length", Len(sRequest)
oHTTP.send sRequest
HTTPPost = oHTTP.responseText
HTTPBody = oHTTP.responseBody
strFile = sDestFolder & sImageFile
Const ForAppending = 8
set objFSO = CreateObject("Scripting.FileSystemObject")
set objFile = objFSO.OpenTextFile(strFile, ForAppending, True)
objFile.WriteLine("Time Stamp: " & Now)
objFile.WriteLine(HTTPPost)
objFile.Close
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment