<package>
<job>
<runtime>
<named
name="SourceUrl"
helpstring="HTTP檔案位址"
type="string"
required="true"
/>
<named
name="DestinationFile"
helpstring="儲存檔案位址"
type="string"
required="true"
/>
<example>
Example : wget /SourceUrl:"http://xxx/xxx.exe" /DestinationFile:"C:\Documents and Settings\All Users\桌面\xxx.exe"
</example>
<description>
用途:下載Web檔案
版本:1.0
作者:Parkghost</description>
</runtime>
<SCRIPT language="VBScript">
If WScript.Arguments.Named.Exists("SourceUrl") And WScript.Arguments.Named.Exists("DestinationFile") Then
strUrl = WScript.Arguments.Named.Item("SourceUrl")
strFile = WScript.Arguments.Named.Item("DestinationFile")
Const adTypeBinary = 1
Const adSaveCreateOverWrite = 2
Const ForWriting = 2
Dim web, varByteArray, strData, strBuffer, lngCounter, ado
Err.Clear
Set web = Nothing
Set web = CreateObject("WinHttp.WinHttpRequest.5.1")
If web Is Nothing Then Set web = CreateObject("WinHttp.WinHttpRequest")
If web Is Nothing Then Set web = CreateObject("MSXML2.ServerXMLHTTP")
If web Is Nothing Then Set web = CreateObject("Microsoft.XMLHTTP")
web.Open "GET", strURL, False
web.Send
If Err.Number <> 0 Then
SaveWebBinary = False
Set web = Nothing
WScript.Quit
End If
If web.Status <> "200" Then
SaveWebBinary = False
Set web = Nothing
WScript.Quit
End If
varByteArray = web.ResponseBody
Set web = Nothing
'Save the file
'On Error Resume Next
Set ado = Nothing
Set ado = CreateObject("ADODB.Stream")
If ado Is Nothing Then
Set fs = CreateObject("Scripting.FileSystemObject")
Set ts = fs.OpenTextFile(strFile, ForWriting, True)
strData = ""
strBuffer = ""
For lngCounter = 0 to UBound(varByteArray)
ts.Write Chr(255 And Ascb(Midb(varByteArray,lngCounter + 1, 1)))
Next
ts.Close
Else
ado.Type = adTypeBinary
ado.Open
ado.Write varByteArray
ado.SaveToFile strFile, adSaveCreateOverWrite
ado.Close
End If
SaveWebBinary = True
Else
WScript.Arguments.ShowUsage()
End if
</SCRIPT>
</job>
</package>
Jan 23, 2008
vbscript 版 wget
PingList.vbs
Subscribe to:
Post Comments (Atom)
2 comments:
Great website, looks very professional. Keep up the good work!
QTP Training in Chennai
QTP Course in Chennai
QTP Training in Porur
QTP Training in T Nagar
LoadRunner Training in Chennai
hp loadrunner training
javascript training in chennai
core java training in chennai
Excellent Articles are shared!!! Here I Grasp lots of things Regarding Technically for My feature reference.Looking for More Updates
Java training in chennai | Java training in annanagar | Java training in omr | Java training in porur | Java training in tambaram | Java training in velachery
Post a Comment