Windows Script Host
Line:7
Char:1
Error:Permission denied
Code:800a0046
Source:Microsoft VBScript runtime error
Expand|Select|Wrap|Line Numbers
- 'define vars
- url = "http://google.com"
- path = "C:\temp.txt"
- 'instantiate
- Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
- Set fso = CreateObject("Scripting.FileSystemObject")
- Set txtfile = fso.OpenTextFile(path, 2, True)
- Set oWS = WScript.CreateObject("WScript.Shell")
- 'make request
- xmlhttp.open "GET", url, false
- xmlhttp.send ""
- 'wait for response
- xmlhttp.waitForResponse()
- 'if status is 200, then it's OK
- if xmlhttp.status = 200 then
- txtfile.WriteLine(xmlhttp.responseText)
- txtfile.Close
- 'enable this to print
- oWS.Run "NotePad.exe /p " + path
- 'enable this to just display
- oWS.Run "notepad.exe " + path
- else
- 'popup bad response, or just omit to end
- WScript.Echo("bad response")
- end if
- 'destroy objects. I'm not sure this is necessary
- Set txtfile = nothing
- Set xmlhttp = nothing
- Set oWS = nothing
- Set fso = nothing