From 036002d8856a1bd6707fddf97ef2f35ef14400f7 Mon Sep 17 00:00:00 2001
From: Michael Jerris <mike@jerris.com>
Date: Mon, 28 Aug 2006 02:01:41 +0000
Subject: [PATCH] use different bat file names so multi proc systems can
 download more than one lib at a time without failing.

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2414 d0543943-73ff-0310-b7d9-9358b9ac24b2
---
 libs/win32/util.vbs | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/libs/win32/util.vbs b/libs/win32/util.vbs
index b2cedcd6c7..2c894bbc84 100644
--- a/libs/win32/util.vbs
+++ b/libs/win32/util.vbs
@@ -25,7 +25,7 @@ If Not IsObject(oStream)  Then
 Else
 	UseWgetEXE=false
 End If
-
+Randomize
 Set objArgs = WScript.Arguments
 quote=Chr(34)
 ScriptDir=Left(WScript.ScriptFullName,Len(WScript.ScriptFullName)-Len(WScript.ScriptName))
@@ -91,19 +91,20 @@ Sub GetWgetEXE(DestFolder)
 End Sub
 
 Sub UnCompress(Archive, DestFolder)
+	batname = "tmp" & CStr(Int(10000*Rnd)) & ".bat"
 	wscript.echo("Extracting: " & Archive)
-	Set MyFile = fso.CreateTextFile(UtilsDir & "tmpcmd.Bat", True)
+	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 & "tmpcmd.Bat")
+	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 & "tmpcmd.Bat", True)
+		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 & "tmpcmd.Bat")
+		Set oExec = WshShell.Exec(UtilsDir & batname)
 		Do
 			WScript.Echo OExec.StdOut.ReadLine()
 		Loop While Not OExec.StdOut.atEndOfStream
@@ -111,10 +112,10 @@ Sub UnCompress(Archive, DestFolder)
 		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 & "tmpcmd.Bat", True)
+		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 & "tmpcmd.Bat")
+		Set oExec = WshShell.Exec(UtilsDir & batname)
 		Do
 			WScript.Echo OExec.StdOut.ReadLine()
 		Loop While Not OExec.StdOut.atEndOfStream
@@ -123,6 +124,9 @@ Sub UnCompress(Archive, DestFolder)
 	End If
 	
 	WScript.Sleep(500)
+	If FSO.FileExists(UtilsDir & batname)Then  
+		FSO.DeleteFile UtilsDir & batname, True
+	End If
 End Sub
 
 Sub Wget(URL, DestFolder)
@@ -134,11 +138,12 @@ Sub Wget(URL, DestFolder)
 	Wscript.echo("Downloading: " & URL)
 	
 If UseWgetEXE Then
-	Set MyFile = fso.CreateTextFile(UtilsDir & "tmpcmd.Bat", True)
+	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 & "tmpcmd.Bat")
+	Set oExec = WshShell.Exec(UtilsDir & batname)
 	Do
 		WScript.Echo OExec.StdOut.ReadLine()
 	Loop While Not OExec.StdOut.atEndOfStream