url = "http://ip-filter.emulefuture.de/download.php?file=ipfilter.zip"
filepath = Replace(WScript.ScriptFullName, WScript.ScriptName, "")
zipname = filepath & "ipfilter.zip"
'download/unzip/cleanup
HTTPDownload url, zipname
Unzip zipname, filepath
CreateObject("Scripting.FileSystemObject").DeleteFile(zipname)
Sub HTTPDownload(strFileURL, strHDLocation)
' Fetch the file
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
objXMLHTTP.open "GET", strFileURL, false
objXMLHTTP.send()
If objXMLHTTP.Status = 200 Then
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1 'adTypeBinary
objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0 'Set the stream position to the start
Set objFSO = Createobject("Scripting.FileSystemObject")
If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
Set objFSO = Nothing
objADOStream.SaveToFile strHDLocation
objADOStream.Close
Set objADOStream = Nothing
End if
Set objXMLHTTP = Nothing
End Sub 'HTTPDownload
Sub Unzip(ZipFile, ExtractTo)
'If the extraction location does not exist create it.
Set fso = CreateObject("Scripting.FileSystemObject")
If NOT fso.FolderExists(ExtractTo) Then
fso.CreateFolder(ExtractTo)
End If
'Extract the contants of the zip file.
set objShell = CreateObject("Shell.Application")
set FilesInZip=objShell.NameSpace(ZipFile).items
objShell.NameSpace(ExtractTo).CopyHere FilesInZip, 16
Set fso = Nothing
Set objShell = Nothing
End Sub 'Unzip
filepath = Replace(WScript.ScriptFullName, WScript.ScriptName, "")
zipname = filepath & "ipfilter.zip"
'download/unzip/cleanup
HTTPDownload url, zipname
Unzip zipname, filepath
CreateObject("Scripting.FileSystemObject").DeleteFile(zipname)
Sub HTTPDownload(strFileURL, strHDLocation)
' Fetch the file
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
objXMLHTTP.open "GET", strFileURL, false
objXMLHTTP.send()
If objXMLHTTP.Status = 200 Then
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1 'adTypeBinary
objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0 'Set the stream position to the start
Set objFSO = Createobject("Scripting.FileSystemObject")
If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
Set objFSO = Nothing
objADOStream.SaveToFile strHDLocation
objADOStream.Close
Set objADOStream = Nothing
End if
Set objXMLHTTP = Nothing
End Sub 'HTTPDownload
Sub Unzip(ZipFile, ExtractTo)
'If the extraction location does not exist create it.
Set fso = CreateObject("Scripting.FileSystemObject")
If NOT fso.FolderExists(ExtractTo) Then
fso.CreateFolder(ExtractTo)
End If
'Extract the contants of the zip file.
set objShell = CreateObject("Shell.Application")
set FilesInZip=objShell.NameSpace(ZipFile).items
objShell.NameSpace(ExtractTo).CopyHere FilesInZip, 16
Set fso = Nothing
Set objShell = Nothing
End Sub 'Unzip
No comments:
Post a Comment