From b948b11b9350af8760b3db17ff6ecdf6b3db0e42 Mon Sep 17 00:00:00 2001
From: Michael Jerris <mike@jerris.com>
Date: Sat, 21 Feb 2009 00:03:22 +0000
Subject: [PATCH] Add auto-downloading libtiff to spandsp build

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12212 d0543943-73ff-0310-b7d9-9358b9ac24b2
---
 libs/spandsp/src/Makefile.am                  |   3 +
 libs/spandsp/src/libspandsp.2005.sln          |  20 ++
 libs/spandsp/src/libspandsp.2008.sln          |  28 +++
 .../src/msvc/Download_TIFF.2005.vcproj        |  49 +++++
 .../src/msvc/Download_TIFF.2008.vcproj        |  49 +++++
 libs/spandsp/src/msvc/tiff/cleancount         |   1 +
 libs/spandsp/src/msvc/util.vbs                | 199 ++++++++++++++++++
 7 files changed, 349 insertions(+)
 create mode 100644 libs/spandsp/src/msvc/Download_TIFF.2005.vcproj
 create mode 100644 libs/spandsp/src/msvc/Download_TIFF.2008.vcproj
 create mode 100644 libs/spandsp/src/msvc/tiff/cleancount
 create mode 100644 libs/spandsp/src/msvc/util.vbs

diff --git a/libs/spandsp/src/Makefile.am b/libs/spandsp/src/Makefile.am
index 8ce5d9e123..1169b3bb57 100644
--- a/libs/spandsp/src/Makefile.am
+++ b/libs/spandsp/src/Makefile.am
@@ -44,6 +44,9 @@ EXTRA_DIST = floating_fudge.h \
              msvc/make_modem_filter.2008.vcproj \
              msvc/make_at_dictionary.2005.vcproj \
              msvc/make_modem_filter.2005.vcproj \
+             msvc/Download_TIFF.2008.vcproj \
+             msvc/Download_TIFF.2005.vcproj \
+             msvc/tiff/cleancout \
              msvc/msvcproj.head \
              msvc/msvcproj.foot \
              msvc/vc8proj.head \
diff --git a/libs/spandsp/src/libspandsp.2005.sln b/libs/spandsp/src/libspandsp.2005.sln
index 5efdaf0454..b78079b0c3 100644
--- a/libs/spandsp/src/libspandsp.2005.sln
+++ b/libs/spandsp/src/libspandsp.2005.sln
@@ -11,25 +11,45 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspandsp", "libspandsp.20
 	EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtiff", "libtiff.2005.vcproj", "{401A40CD-5DB4-4E34-AC68-FA99E9FAC014}"
+	ProjectSection(ProjectDependencies) = postProject
+		{2B8A45C9-FEB4-4734-AB37-8DB9DB899917} = {2B8A45C9-FEB4-4734-AB37-8DB9DB899917}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Download TIFF", "msvc\Download_TIFF.2005.vcproj", "{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		All|Win32 = All|Win32
 		Debug|Win32 = Debug|Win32
 		Release|Win32 = Release|Win32
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{DEE932AB-5911-4700-9EEB-8C7090A0A330}.All|Win32.ActiveCfg = All|Win32
+		{DEE932AB-5911-4700-9EEB-8C7090A0A330}.All|Win32.Build.0 = All|Win32
 		{DEE932AB-5911-4700-9EEB-8C7090A0A330}.Debug|Win32.ActiveCfg = All|Win32
 		{DEE932AB-5911-4700-9EEB-8C7090A0A330}.Release|Win32.ActiveCfg = All|Win32
+		{329A6FA0-0FCC-4435-A950-E670AEFA9838}.All|Win32.ActiveCfg = All|Win32
+		{329A6FA0-0FCC-4435-A950-E670AEFA9838}.All|Win32.Build.0 = All|Win32
 		{329A6FA0-0FCC-4435-A950-E670AEFA9838}.Debug|Win32.ActiveCfg = All|Win32
 		{329A6FA0-0FCC-4435-A950-E670AEFA9838}.Release|Win32.ActiveCfg = All|Win32
+		{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.All|Win32.ActiveCfg = Release|Win32
+		{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.All|Win32.Build.0 = Release|Win32
 		{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Debug|Win32.ActiveCfg = Debug|Win32
 		{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Debug|Win32.Build.0 = Debug|Win32
 		{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Release|Win32.ActiveCfg = Release|Win32
 		{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Release|Win32.Build.0 = Release|Win32
+		{401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.All|Win32.ActiveCfg = Release|Win32
+		{401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.All|Win32.Build.0 = Release|Win32
 		{401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Debug|Win32.ActiveCfg = Debug|Win32
 		{401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Debug|Win32.Build.0 = Debug|Win32
 		{401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Release|Win32.ActiveCfg = Release|Win32
 		{401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Release|Win32.Build.0 = Release|Win32
+		{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.All|Win32.ActiveCfg = All|Win32
+		{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.All|Win32.Build.0 = All|Win32
+		{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Debug|Win32.ActiveCfg = All|Win32
+		{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Debug|Win32.Build.0 = All|Win32
+		{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Release|Win32.ActiveCfg = All|Win32
+		{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Release|Win32.Build.0 = All|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
diff --git a/libs/spandsp/src/libspandsp.2008.sln b/libs/spandsp/src/libspandsp.2008.sln
index fd9bc745d6..2602184d38 100644
--- a/libs/spandsp/src/libspandsp.2008.sln
+++ b/libs/spandsp/src/libspandsp.2008.sln
@@ -11,25 +11,41 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libspandsp", "libspandsp.20
 	EndProjectSection
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libtiff", "libtiff.2008.vcproj", "{401A40CD-5DB4-4E34-AC68-FA99E9FAC014}"
+	ProjectSection(ProjectDependencies) = postProject
+		{2B8A45C9-FEB4-4734-AB37-8DB9DB899917} = {2B8A45C9-FEB4-4734-AB37-8DB9DB899917}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Download TIFF", "msvc\Download_TIFF.2008.vcproj", "{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		All|Win32 = All|Win32
+		All|x64 = All|x64
 		Debug|Win32 = Debug|Win32
 		Debug|x64 = Debug|x64
 		Release|Win32 = Release|Win32
 		Release|x64 = Release|x64
 	EndGlobalSection
 	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{DEE932AB-5911-4700-9EEB-8C7090A0A330}.All|Win32.ActiveCfg = All|Win32
+		{DEE932AB-5911-4700-9EEB-8C7090A0A330}.All|Win32.Build.0 = All|Win32
+		{DEE932AB-5911-4700-9EEB-8C7090A0A330}.All|x64.ActiveCfg = All|Win32
 		{DEE932AB-5911-4700-9EEB-8C7090A0A330}.Debug|Win32.ActiveCfg = All|Win32
 		{DEE932AB-5911-4700-9EEB-8C7090A0A330}.Debug|Win32.Build.0 = All|Win32
 		{DEE932AB-5911-4700-9EEB-8C7090A0A330}.Debug|x64.ActiveCfg = All|Win32
 		{DEE932AB-5911-4700-9EEB-8C7090A0A330}.Release|Win32.ActiveCfg = All|Win32
 		{DEE932AB-5911-4700-9EEB-8C7090A0A330}.Release|x64.ActiveCfg = All|Win32
+		{329A6FA0-0FCC-4435-A950-E670AEFA9838}.All|Win32.ActiveCfg = All|Win32
+		{329A6FA0-0FCC-4435-A950-E670AEFA9838}.All|Win32.Build.0 = All|Win32
+		{329A6FA0-0FCC-4435-A950-E670AEFA9838}.All|x64.ActiveCfg = All|Win32
 		{329A6FA0-0FCC-4435-A950-E670AEFA9838}.Debug|Win32.ActiveCfg = All|Win32
 		{329A6FA0-0FCC-4435-A950-E670AEFA9838}.Debug|Win32.Build.0 = All|Win32
 		{329A6FA0-0FCC-4435-A950-E670AEFA9838}.Debug|x64.ActiveCfg = All|Win32
 		{329A6FA0-0FCC-4435-A950-E670AEFA9838}.Release|Win32.ActiveCfg = All|Win32
 		{329A6FA0-0FCC-4435-A950-E670AEFA9838}.Release|x64.ActiveCfg = All|Win32
+		{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.All|Win32.ActiveCfg = Release|x64
+		{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.All|x64.ActiveCfg = Release|x64
+		{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.All|x64.Build.0 = Release|x64
 		{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Debug|Win32.ActiveCfg = Debug|Win32
 		{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Debug|Win32.Build.0 = Debug|Win32
 		{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Debug|x64.ActiveCfg = Debug|x64
@@ -38,6 +54,9 @@ Global
 		{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Release|Win32.Build.0 = Release|Win32
 		{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Release|x64.ActiveCfg = Release|x64
 		{1CBB0077-18C5-455F-801C-0A0CE7B0BBF5}.Release|x64.Build.0 = Release|x64
+		{401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.All|Win32.ActiveCfg = Release|x64
+		{401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.All|x64.ActiveCfg = Release|x64
+		{401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.All|x64.Build.0 = Release|x64
 		{401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Debug|Win32.ActiveCfg = Debug|Win32
 		{401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Debug|Win32.Build.0 = Debug|Win32
 		{401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Debug|x64.ActiveCfg = Debug|x64
@@ -46,6 +65,15 @@ Global
 		{401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Release|Win32.Build.0 = Release|Win32
 		{401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Release|x64.ActiveCfg = Release|x64
 		{401A40CD-5DB4-4E34-AC68-FA99E9FAC014}.Release|x64.Build.0 = Release|x64
+		{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.All|Win32.ActiveCfg = All|Win32
+		{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.All|Win32.Build.0 = All|Win32
+		{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.All|x64.ActiveCfg = All|Win32
+		{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Debug|Win32.ActiveCfg = All|Win32
+		{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Debug|Win32.Build.0 = All|Win32
+		{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Debug|x64.ActiveCfg = All|Win32
+		{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Release|Win32.ActiveCfg = All|Win32
+		{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Release|Win32.Build.0 = All|Win32
+		{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}.Release|x64.ActiveCfg = All|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
diff --git a/libs/spandsp/src/msvc/Download_TIFF.2005.vcproj b/libs/spandsp/src/msvc/Download_TIFF.2005.vcproj
new file mode 100644
index 0000000000..d585351882
--- /dev/null
+++ b/libs/spandsp/src/msvc/Download_TIFF.2005.vcproj
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="8.00"
+	Name="Download TIFF"
+	ProjectGUID="{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}"
+	RootNamespace="Download TIFF"
+	Keyword="Win32Proj"
+	TargetFrameworkVersion="131072"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="All|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="10"
+			CharacterSet="2"
+			BuildLogFile="$(IntDir)\BuildLog $(ProjectName).htm"
+			>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<File
+			RelativePath=".\tiff\cleancount"
+			>
+			<FileConfiguration
+				Name="All|Win32"
+				>
+				<Tool
+					Name="VCCustomBuildTool"
+					Description="Downloading Tiff."
+					CommandLine="if not exist &quot;$(ProjectDir)..\..\..\tiff-3.8.2&quot; cscript /nologo &quot;$(ProjectDir)util.vbs&quot; GetUnzip http://svn.freeswitch.org/downloads/libs/tiff-3.8.2.tar.gz &quot;$(ProjectDir)..\..\..&quot;&#x0D;&#x0A;"
+					Outputs="$(ProjectDir)..\..\..\tiff-3.8.2"
+				/>
+			</FileConfiguration>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
diff --git a/libs/spandsp/src/msvc/Download_TIFF.2008.vcproj b/libs/spandsp/src/msvc/Download_TIFF.2008.vcproj
new file mode 100644
index 0000000000..a7bc466047
--- /dev/null
+++ b/libs/spandsp/src/msvc/Download_TIFF.2008.vcproj
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="Download TIFF"
+	ProjectGUID="{2B8A45C9-FEB4-4734-AB37-8DB9DB899917}"
+	RootNamespace="Download TIFF"
+	Keyword="Win32Proj"
+	TargetFrameworkVersion="131072"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="All|Win32"
+			OutputDirectory="$(SolutionDir)$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="10"
+			CharacterSet="2"
+			BuildLogFile="$(IntDir)\BuildLog $(ProjectName).htm"
+			>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<File
+			RelativePath=".\tiff\cleancount"
+			>
+			<FileConfiguration
+				Name="All|Win32"
+				>
+				<Tool
+					Name="VCCustomBuildTool"
+					Description="Downloading Tiff."
+					CommandLine="if not exist &quot;$(ProjectDir)..\..\..\tiff-3.8.2&quot; cscript /nologo &quot;$(ProjectDir)util.vbs&quot; GetUnzip http://svn.freeswitch.org/downloads/libs/tiff-3.8.2.tar.gz &quot;$(ProjectDir)..\..\..&quot;&#x0D;&#x0A;"
+					Outputs="$(ProjectDir)..\..\..\tiff-3.8.2"
+				/>
+			</FileConfiguration>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
diff --git a/libs/spandsp/src/msvc/tiff/cleancount b/libs/spandsp/src/msvc/tiff/cleancount
new file mode 100644
index 0000000000..56a6051ca2
--- /dev/null
+++ b/libs/spandsp/src/msvc/tiff/cleancount
@@ -0,0 +1 @@
+1
\ No newline at end of file
diff --git a/libs/spandsp/src/msvc/util.vbs b/libs/spandsp/src/msvc/util.vbs
new file mode 100644
index 0000000000..c8668850d1
--- /dev/null
+++ b/libs/spandsp/src/msvc/util.vbs
@@ -0,0 +1,199 @@
+'
+' Contributor(s):
+' Michael Jerris <mike@jerris.com>
+' David A. Horner http://dave.thehorners.com
+'----------------------------------------------
+
+'On Error Resume Next
+' **************
+' Initialization
+' **************
+
+Set WshShell = CreateObject("WScript.Shell")
+Set FSO = CreateObject("Scripting.FileSystemObject")
+Set WshSysEnv = WshShell.Environment("SYSTEM")
+Set xml = CreateObject("Microsoft.XMLHTTP")
+Dim UseWgetEXE
+
+On Error Resume Next
+Set oStream = CreateObject("Adodb.Stream")
+On Error Goto 0
+
+If Not IsObject(oStream)  Then
+	wscript.echo("Failed to create Adodb.Stream, using alternative download method.")
+	UseWgetEXE=true
+Else
+	UseWgetEXE=false
+End If
+Randomize
+Set objArgs = WScript.Arguments
+quote=Chr(34)
+ScriptDir=Left(WScript.ScriptFullName,Len(WScript.ScriptFullName)-Len(WScript.ScriptName))
+UtilsDir=Showpath(ScriptDir)
+ToolsBase="http://svn.freeswitch.org/downloads/win32/"
+
+If UseWgetEXE Then
+	GetWgetEXE UtilsDir
+End If
+
+GetCompressionTools UtilsDir
+
+
+If objArgs.Count >=3 Then
+	Select Case objArgs(0)
+		Case "Get"		
+			Wget objArgs(1), Showpath(objArgs(2))
+		Case "GetUnzip"		
+			WgetUnCompress objArgs(1), Showpath(objArgs(2))
+	End Select
+End If
+
+
+' *******************
+' Utility Subroutines
+' *******************
+
+
+Sub WgetUnCompress(URL, DestFolder)
+	If Right(DestFolder, 1) <> "\" Then DestFolder = DestFolder & "\" End If
+	StartPos = InstrRev(URL, "/", -1, 1) 
+	strlength = Len(URL)
+	filename=Right(URL,strlength-StartPos)
+	NameEnd = InstrRev(filename, ".",-1, 1)
+	filestrlength = Len(filename)
+	filebase = Left(filename,NameEnd)
+	fileext = Right(filename, Len(filename) - NameEnd)
+	Wget URL, DestFolder
+	If fileext = "zip" Then
+		UnCompress Destfolder & filename, DestFolder & filebase
+	Else
+		UnCompress Destfolder & filename, DestFolder	
+	End If
+End Sub
+
+Sub GetCompressionTools(DestFolder)
+	Dim oExec
+	If Right(DestFolder, 1) <> "\" Then DestFolder = DestFolder & "\" End If
+	If Not FSO.FileExists(DestFolder & "7za.exe") Then 
+		If Not FSO.FileExists(DestFolder & "7za.tag") Then 
+			Set MyFile = fso.CreateTextFile(DestFolder & "7za.tag", True)
+			MyFile.WriteLine("This file marks a pending download for 7za.exe so we don't download it twice at the same time")
+			MyFile.Close
+				
+				Wget ToolsBase & "7za.exe", DestFolder
+			
+			FSO.DeleteFile DestFolder & "7za.tag" ,true 
+		Else
+			WScript.Sleep(5000)
+		End If	
+	End If	
+End Sub
+
+Sub GetWgetEXE(DestFolder)
+	Dim oExec
+	If Right(DestFolder, 1) <> "\" Then DestFolder = DestFolder & "\" End If
+	If Not FSO.FileExists(DestFolder & "wget.exe") Then 
+		Slow_Wget ToolsBase & "wget.exe", DestFolder
+	End If	
+End Sub
+
+Sub UnCompress(Archive, DestFolder)
+	batname = "tmp" & CStr(Int(10000*Rnd)) & ".bat"
+	wscript.echo("Extracting: " & Archive)
+	Set MyFile = fso.CreateTextFile(UtilsDir & batname, True)
+	MyFile.WriteLine("@" & quote & UtilsDir & "7za.exe" & quote & " x " & quote & Archive & quote & " -y -o" & quote & DestFolder & quote )
+	MyFile.Close
+	Set oExec = WshShell.Exec(UtilsDir & batname)
+	Do
+		WScript.Echo OExec.StdOut.ReadLine()
+	Loop While Not OExec.StdOut.atEndOfStream
+	If FSO.FileExists(Left(Archive, Len(Archive)-3))Then  
+		Set MyFile = fso.CreateTextFile(UtilsDir & batname, True)
+		MyFile.WriteLine("@" & quote & UtilsDir & "7za.exe" & quote & " x " & quote & Left(Archive, Len(Archive)-3) & quote & " -y -o" & quote & DestFolder & quote )
+		MyFile.Close
+		Set oExec = WshShell.Exec(UtilsDir & batname)
+		Do
+			WScript.Echo OExec.StdOut.ReadLine()
+		Loop While Not OExec.StdOut.atEndOfStream
+		WScript.Sleep(500)
+		FSO.DeleteFile Left(Archive, Len(Archive)-3) ,true 
+	End If
+	If FSO.FileExists(Left(Archive, Len(Archive)-3) & "tar")Then  
+		Set MyFile = fso.CreateTextFile(UtilsDir & batname, True)
+		MyFile.WriteLine("@" & quote & UtilsDir & "7za.exe" & quote & " x " & quote & Left(Archive, Len(Archive)-3) & "tar" & quote & " -y -o" & quote & DestFolder & quote )
+		MyFile.Close
+		Set oExec = WshShell.Exec(UtilsDir & batname)
+		Do
+			WScript.Echo OExec.StdOut.ReadLine()
+		Loop While Not OExec.StdOut.atEndOfStream
+		WScript.Sleep(500)
+		FSO.DeleteFile Left(Archive, Len(Archive)-3) & "tar",true 
+	End If
+	
+	WScript.Sleep(500)
+	If FSO.FileExists(UtilsDir & batname)Then  
+		FSO.DeleteFile UtilsDir & batname, True
+	End If
+End Sub
+
+Sub Wget(URL, DestFolder)
+	StartPos = InstrRev(URL, "/", -1, 1)   
+	strlength = Len(URL)
+	filename=Right(URL,strlength-StartPos)
+	If Right(DestFolder, 1) <> "\" Then DestFolder = DestFolder & "\" End If
+
+	Wscript.echo("Downloading: " & URL)
+	
+If UseWgetEXE Then
+	batname = "tmp" & CStr(Int(10000*Rnd)) & ".bat"
+	Set MyFile = fso.CreateTextFile(UtilsDir & batname, True)
+	MyFile.WriteLine("@cd " & quote & DestFolder & quote)
+	MyFile.WriteLine("@" & quote & UtilsDir & "wget.exe" & quote & " " & URL)
+	MyFile.Close
+	Set oExec = WshShell.Exec(UtilsDir & batname)
+	Do
+		WScript.Echo OExec.StdOut.ReadLine()
+	Loop While Not OExec.StdOut.atEndOfStream
+
+Else
+	xml.Open "GET", URL, False
+	xml.Send
+	
+	Const adTypeBinary = 1
+	Const adSaveCreateOverWrite = 2
+	Const adSaveCreateNotExist = 1 
+
+	oStream.type = adTypeBinary
+	oStream.open
+	oStream.write xml.responseBody
+	oStream.savetofile DestFolder & filename, adSaveCreateOverWrite
+	oStream.close
+End If
+
+End Sub
+
+Sub Slow_Wget(URL, DestFolder)
+	StartPos = InstrRev(URL, "/", -1, 1)   
+	strlength = Len(URL)
+	filename=Right(URL,strlength-StartPos)
+	If Right(DestFolder, 1) <> "\" Then DestFolder = DestFolder & "\" End If
+
+	Wscript.echo("Downloading: " & URL)
+	xml.Open "GET", URL, False
+	xml.Send
+	
+	const ForReading = 1 , ForWriting = 2 , ForAppending = 8 
+	Set MyFile = fso.OpenTextFile(DestFolder & filename ,ForWriting, True)
+	For i = 1 to lenb(xml.responseBody)
+	 MyFile.write Chr(Ascb(midb(xml.responseBody,i,1)))
+	Next
+	MyFile.Close()
+
+End Sub
+
+Function Showpath(folderspec)
+	Set f = FSO.GetFolder(folderspec)
+	showpath = f.path & "\"
+End Function
+
+