daily pastebin goal
35%
SHARE
TWEET

Gatherer

sweenig Jan 3rd, 2014 1,391 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'call with 2 parameters, the name of the server to fetch from and the name of the file to fetch
  2. dim xHttp 'create http getter object pointer
  3. set xHttp = createobject("Microsoft.XMLHTTP") 'create http getter object
  4. dim bStrm 'create bitstream object pointer
  5. set bStrm = createobject("Adodb.Stream") 'create bitstream object
  6. dim targetServer 'holds the name of the server
  7. targetServer = WScript.Arguments(0) 'take the first argument and put it into targetServer
  8. dim targetURL 'holds the final url
  9. targetURL = "http://" & targetServer & "/" & WScript.Arguments(1)
  10. WScript.echo "Fetching " & WScript.Arguments(1) &" from " & targetURL & "..."
  11. xHttp.Open "GET", targetURL & "?" & Rnd,False 'setup the get instruction
  12. xHttp.Send 'get the file
  13. WScript.echo "HTTP Response Code: " & xHttp.status
  14. if xHttp.status>=400 and xHttp.status <=599 then
  15.         WScript.echo targetURL & " was not found on " & targetServer
  16.         WScript.Quit 1
  17. Else
  18.         'get the current working directory
  19.         dim fso
  20.         dim curDir
  21.         set fso = CreateObject("Scripting.FileSystemObject")
  22.         curDir = fso.GetAbsolutePathName(".")
  23.         set fso = nothing
  24.         'done getting the current working directory
  25.         with bStrm
  26.                 .type = 1 'set to binary mode
  27.                 .open 'open the stream
  28.                 .write xHttp.responseBody 'write the response of the http get to the stream
  29.                 WScript.echo "Saving to " & curDir & "\" & WScript.Arguments(1) & targetServer
  30.                 .savetofile curDir & "\" & WScript.Arguments(1) & targetServer, 2 'save the stream to a file, overwriting
  31.         end with
  32. End If
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top