Sub GetCompressionTools(DestFolder)\r
Dim tries\r
Dim max_tries\r
+ Dim MyFile\r
+\r
tries = 0\r
max_tries = 10\r
If Right(DestFolder, 1) <> "\" Then DestFolder = DestFolder & "\" End If\r
FSO.DeleteFile DestFolder & "7za.tag", true\r
Wscript.echo("Downloaded 7za.exe")\r
End If\r
+ Set MyFile = Nothing\r
WScript.Sleep(500)\r
End If\r
Do While FSO.FileExists(DestFolder & "7za.tag") And tries < max_tries\r
Strip = Right(oRE.Replace(Str, ""), 20)\r
End Function\r
\r
+Sub ExecPrintOutput(Str)\r
+ Dim Process\r
+\r
+ Set Process = WshShell.Exec(Str)\r
+\r
+ Do\r
+ If Not Process.StdOut.atEndOfStream Then\r
+ WScript.Echo Process.StdOut.ReadLine()\r
+ End If\r
+ Loop Until (Process.Status <> 0) And (Process.StdOut.atEndOfStream)\r
+\r
+ Process.Terminate \r
+ WScript.Sleep(500)\r
+End Sub\r
+\r
Sub UnCompress(Archive, DestFolder)\r
Dim Fn\r
Dim batname\r
- \r
+ Dim MyFile\r
+\r
GetCompressionTools UtilsDir\r
- \r
+\r
batname = "tmp" & Strip(Archive) & CStr(Int(10000*Rnd)) & ".bat"\r
wscript.echo("Extracting: " & Archive & " - using: " & batname)\r
- Set MyFile = fso.CreateTextFile(UtilsDir & batname, True)\r
+ Set MyFile = FSO.CreateTextFile(UtilsDir & batname, True)\r
MyFile.WriteLine("@" & quote & UtilsDir & "7za.exe" & quote & " x " & quote & Archive & quote & " -y -o" & quote & DestFolder & quote )\r
MyFile.Close\r
- Set oExec = WshShell.Exec(UtilsDir & batname)\r
- Do\r
- WScript.Echo OExec.StdOut.ReadLine()\r
- Loop While Not OExec.StdOut.atEndOfStream\r
+ Set MyFile = Nothing\r
+ ExecPrintOutput(UtilsDir & batname)\r
wscript.echo("Ready extracting: " & Archive)\r
Fn = Left(Archive, Len(Archive)-3)\r
If FSO.FileExists(Fn) Then\r
Set MyFile = FSO.CreateTextFile(UtilsDir & batname, True)\r
MyFile.WriteLine("@" & quote & UtilsDir & "7za.exe" & quote & " x " & quote & Fn & quote & " -y -o" & quote & DestFolder & quote )\r
MyFile.Close\r
- Set oExec = WshShell.Exec(UtilsDir & batname)\r
- Do\r
- WScript.Echo OExec.StdOut.ReadLine()\r
- Loop While Not OExec.StdOut.atEndOfStream\r
+ Set MyFile = Nothing\r
+ ExecPrintOutput(UtilsDir & batname)\r
wscript.echo("Ready extracting: " & Fn)\r
- WScript.Sleep(500)\r
wscript.echo("Deleting: " & Fn)\r
FSO.DeleteFile Fn,true\r
End If\r
Set MyFile = FSO.CreateTextFile(UtilsDir & batname, True)\r
MyFile.WriteLine("@" & quote & UtilsDir & "7za.exe" & quote & " x " & quote & Fn & quote & " -y -o" & quote & DestFolder & quote )\r
MyFile.Close\r
- Set oExec = WshShell.Exec(UtilsDir & batname)\r
- Do\r
- WScript.Echo OExec.StdOut.ReadLine()\r
- Loop While Not OExec.StdOut.atEndOfStream\r
+ Set MyFile = Nothing\r
+ ExecPrintOutput(UtilsDir & batname)\r
wscript.echo("Ready extracting: " & Fn )\r
- WScript.Sleep(500)\r
wscript.echo("Deleting: " & Fn)\r
FSO.DeleteFile Fn,true\r
End If\r
End Sub\r
\r
Sub Wget(URL, DestFolder)\r
+ Dim MyFile\r
+\r
StartPos = InstrRev(URL, "/", -1, 1)\r
strlength = Len(URL)\r
filename=Right(URL,strlength-StartPos)\r
If UseWgetEXE Then\r
Wscript.echo("wget: " & URL)\r
batname = "tmp" & CStr(Int(10000*Rnd)) & ".bat"\r
- Set MyFile = fso.CreateTextFile(UtilsDir & batname, True)\r
+ Set MyFile = FSO.CreateTextFile(UtilsDir & batname, True)\r
MyFile.WriteLine("@cd " & quote & DestFolder & quote)\r
MyFile.WriteLine("@" & quote & UtilsDir & "wget.exe" & quote & " " & URL)\r
MyFile.Close\r
- Set oExec = WshShell.Exec(UtilsDir & batname)\r
- Do\r
- WScript.Echo OExec.StdOut.ReadLine()\r
- Loop While Not OExec.StdOut.atEndOfStream\r
-\r
+ Set MyFile = Nothing\r
+ ExecPrintOutput(UtilsDir & batname)\r
Else\r
Wscript.echo("XMLHTTP GET: " & URL)\r
\r
End Sub\r
\r
Sub Slow_Wget(URL, DestFolder)\r
+ Dim MyFile\r
+\r
StartPos = InstrRev(URL, "/", -1, 1)\r
strlength = Len(URL)\r
filename=Right(URL,strlength-StartPos)\r
xml.Send\r
\r
const ForReading = 1 , ForWriting = 2 , ForAppending = 8\r
- Set MyFile = fso.OpenTextFile(DestFolder & filename ,ForWriting, True)\r
+ Set MyFile = FSO.OpenTextFile(DestFolder & filename ,ForWriting, True)\r
For i = 1 to lenb(xml.responseBody)\r
MyFile.write Chr(Ascb(midb(xml.responseBody,i,1)))\r
Next\r
MyFile.Close()\r
+ Set MyFile = Nothing\r
\r
End Sub\r
\r
End Sub\r
\r
Function ExecAndGetResult(tmpFolder, VersionDir, execStr)\r
+ Dim MyFile\r
+\r
Set MyFile = FSO.CreateTextFile(tmpFolder & "tmpExec.Bat", True)\r
MyFile.WriteLine("@" & "cd " & quote & VersionDir & quote)\r
MyFile.WriteLine("@" & execStr)\r
MyFile.Close\r
+ Set MyFile = Nothing\r
\r
Set oExec = WshShell.Exec("cmd /C " & quote & tmpFolder & "tmpExec.Bat" & quote)\r
\r
ExecAndGetResult = Trim(OExec.StdOut.ReadLine())\r
\r
Do\r
- Loop While Not OExec.StdOut.atEndOfStream\r
+ Loop Until (oExec.Status <> 0) And (oExec.StdOut.atEndOfStream)\r
+\r
+ oExec.Terminate \r
+ WScript.Sleep(500)\r
\r
FSO.DeleteFile(tmpFolder & "tmpExec.Bat")\r
\r
End Function\r
\r
Function ExecAndGetExitCode(tmpFolder, VersionDir, execStr)\r
+ Dim MyFile\r
\r
Set MyFile = FSO.CreateTextFile(tmpFolder & "tmpExec.Bat", True)\r
MyFile.WriteLine("@" & "cd " & quote & VersionDir & quote)\r
MyFile.WriteLine("@" & execStr)\r
MyFile.WriteLine("@exit %ERRORLEVEL%")\r
MyFile.Close\r
+ Set MyFile = Nothing\r
\r
ExecAndGetExitCode = WshShell.Run("cmd /C " & quote & tmpFolder & "tmpExec.Bat" & quote, 0, True)\r
\r
sLastVersion = sLastFile.ReadLine()\r
End If\r
sLastFile.Close\r
+ Set sLastFile = Nothing\r
End If\r
\r
If VERSION & " " & strVerHuman <> sLastVersion Then\r
- Set MyFile = fso.CreateTextFile(tmpFolder & "lastversion", True)\r
+ Dim MyFile\r
+\r
+ Set MyFile = FSO.CreateTextFile(tmpFolder & "lastversion", True)\r
MyFile.WriteLine(VERSION & " " & strVerHuman)\r
MyFile.Close\r
+ Set MyFile = Nothing\r
\r
FSO.CopyFile includebase, includedest, true\r
FindReplaceInFile includedest, "@SWITCH_VERSION_REVISION@", VERSION\r