#RequireAdmin #Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=3xhumed-Mega-Games-Pack-18-Battlefield-1942-Secret-Weapons-of-WWII-2.ico #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #include #include #include Func StartInsTrans($bUpdate=1) $iStatusFile = "C:\JobStatus\ISRunning.txt" if ($bUpdate = 1) Then if not FileExists($iStatusFile) Then FileWrite($iStatusFile,_NowCalc() & " : From BackgroundForBinaries" &@CRLF) Logging("Created Installshield status file: "&$iStatusFile) EndIf Else if FileExists($iStatusFile) Then FileDelete($iStatusFile) Logging("Deleted Installshield status file: "&$iStatusFile) EndIf EndIf EndFunc $MartFolder = "C:\Mart" Local $i = 0 While $i <> 10 Sleep(60000);1min If FileExists(@ScriptDir&"\Binaries.ini") then ;$i = 10 StartInsTrans() WaitForINICompletion(@ScriptDir&"\Binaries.ini") SendMail("Binaries copied to Installshield machine","Got Binaries.ini: Will initmate once Install creation started") Sleep(5000) ;$i = 10 ;MsgBox($MB_SYSTEMMODAL, "", "Value of $i is: " & $i) ChangeWin32(@ScriptDir&"\Binaries.ini") CheckZip(@ScriptDir&"\Binaries.ini") AppendBinaries(@ScriptDir&"\Binaries.ini",@ScriptDir&"\BinaryDetails.ini") if(FileExists(@ScriptDir&"\copy.exe")) then Local $iReturn = Runwait(@ScriptDir&"\copy.exe", "", @SW_MAXIMIZE) if not @error Then ;Logging("execution completed successfully with Return Code: " & $iReturn,4) Else ;Logging("execution failed with Return Code: " & $iReturn,4) EndIf ;FileMove(@ScriptDir&"\BinaryDetails.ini", @ScriptDir&"\BinaryDetails_old.ini", 0) ;MsgBox($MB_SYSTEMMODAL, "", "The return code from CreateSetup was: " & $iReturn) EndIf if(FileExists(@ScriptDir&"\CreateSetup.exe")) then Local $iReturn = Runwait(@ScriptDir&"\CreateSetup.exe", "", @SW_MAXIMIZE) if not @error Then ;Logging("execution completed successfully with Return Code: " & $iReturn,4) Else ;Logging("execution failed with Return Code: " & $iReturn,4) EndIf ;FileMove(@ScriptDir&"\BinaryDetails.ini", @ScriptDir&"\BinaryDetails_old.ini", 0) ;MsgBox($MB_SYSTEMMODAL, "", "The return code from CreateSetup was: " & $iReturn) EndIf StartInsTrans(0) EndIf If FileExists($MartFolder&"\Binaries.ini") then StartInsTrans() ;$i = 10 ;Logging("Updating Git Mart Repo") ;$gitreturn = UpdateGitRepo("C:\git\erwin-Mart","GitMartRepo_Status.txt") ;Logging("Completed Updating with status "+$gitreturn) if(FileExists($MartFolder&"\BuildMart.exe")) then Local $iReturn = Runwait($MartFolder&"\BuildMart.exe", "", @SW_MAXIMIZE) if not @error Then ;Logging("execution completed successfully with Return Code: " & $iReturn,4) Else ;Logging("execution failed with Return Code: " & $iReturn,4) EndIf ;FileMove(@ScriptDir&"\BinaryDetails.ini", @ScriptDir&"\BinaryDetails_old.ini", 0) ;MsgBox($MB_SYSTEMMODAL, "", "The return code from CreateSetup was: " & $iReturn) Else MsgBox($MB_SYSTEMMODAL, "BuildMart not found", $MartFolder&"\BuildMart.exe", 10) EndIf MsgBox($MB_SYSTEMMODAL, "Deleting Binaries of Mart", $MartFolder&"\Binaries.ini", 10) FileDelete($MartFolder&"\Binaries.ini") StartInsTrans(0) EndIf WEnd Func WaitForINICompletion($inifile) $status = false while not $status $x64 = IniRead($inifile, "Binaries", "x64", "Default Value") $x86 = IniRead($inifile, "Binaries", "x86", "Default Value") $win32 = IniRead($inifile, "Binaries", "win32", "Default Value") if not StringCompare($x64,"Default Value")=0 Then if ((not StringCompare($x86,"Default Value")=0) or (not StringCompare($win32,"Default Value")=0)) then $status = true Else ConsoleWrite("Waiting for Binaires.ini to be created completely"&@CRLF) Sleep(5000) $status = false EndIf Else Sleep(5000) $status = false EndIf WEnd EndFunc ;AppendBinaries("C:\Dialy Builds\testing\BinaryDetails.ini","C:\Dialy Builds\Binaries.ini") Func GetDir($sFilePath) If Not IsString($sFilePath) Then Return SetError(1, 0, -1) EndIf Local $FileDir = StringRegExpReplace($sFilePath, "\\[^\\]*$", "") Return $FileDir EndFunc Func GetFileName($sFilePath) If Not IsString($sFilePath) Then Return SetError(1, 0, -1) EndIf Local $FileName = StringRegExpReplace($sFilePath, "^.*\\", "") Return $FileName EndFunc Func AppendBinaries($sFilePath,$sINIPath) ; Create a constant variable in Local scope of the filepath that will be read/written to. ;Local Const $sINIPath = @ScriptDir & "\BinaryDetails.ini" ;$sFilePath = @ScriptDir & "\Binaries.ini" $d = IniRead($sINIPath, "x64", "BinaryFolder", "Default Value") $f = RemoveExt(IniRead($sFilePath, "Binaries", "x64", "Default Value"));RemoveExt:To remove .zip extension if exists IniWrite($sINIPath, "x64", "BinaryFolder", GetDir($d)&"\"&$f) $d = IniRead($sINIPath, "x86", "BinaryFolder", "Default Value") $f = RemoveExt(IniRead($sFilePath, "Binaries", "x86", "Default Value")) IniWrite($sINIPath, "x86", "BinaryFolder", GetDir($d)&"\"&$f) FileDelete($sFilePath) EndFunc ;==>Example Func ChangeWin32($sFilePath);To change win32 section in ini to x86 $x86 = RemoveExt(IniRead($sFilePath, "Binaries", "x86", "Default Value")) $win32 = RemoveExt(IniRead($sFilePath, "Binaries", "win32", "Default Value")) if StringCompare($x86,"Default Value")=0 then if not StringCompare($win32,"Default Value")=0 then IniWrite($sFilePath, "Binaries", "x86", $win32) IniDelete($sFilePath, "Binaries", "win32") EndIf EndIf EndFunc Func CheckZip($sFilePath) ;GetDir($sFilePath) & IniRead($sFilePath, "Binaries", "x64", "Default Value") $x64 = RemoveExt(IniRead($sFilePath, "Binaries", "x64", "Default Value")) ;MsgBox(0,"x64",$x64) if not StringCompare($x64,"Default Value")=0 then If FileExists(GetDir($sFilePath)& "\" & $x64 & ".zip") Then If not FileExists(GetDir($sFilePath)& "\" & $x64) then ExtractZip(GetDir($sFilePath)& "\" & $x64 & ".zip") EndIf EndIf $x86 = RemoveExt(IniRead($sFilePath, "Binaries", "x86", "Default Value")) ;MsgBox(0,"x86",$x86) if not StringCompare($x86,"Default Value")=0 then If FileExists(GetDir($sFilePath)& "\" & $x86 & ".zip") Then If not FileExists(GetDir($sFilePath)& "\" & $x86) then ExtractZip(GetDir($sFilePath)& "\" & $x86 & ".zip") EndIf EndIf EndFunc ;in baclground process 7zip won't work Func ExtractZip_7Zip($sFilePath) FileInstall(".\7z\7za.exe", @ScriptDir & "\7za.exe") FileInstall(".\7z\7za.dll", @ScriptDir & "\7za.dll") FileInstall(".\7z\7zxa.dll", @ScriptDir & "\7zxa.dll") Local $iReturn = RunWait(@ScriptDir &'\7za.exe x "'& $sFilePath &'" -o"' & RemoveExt($sFilePath) & '"') ;MsgBox($MB_SYSTEMMODAL, "", "The return code from 7z was: " & $iReturn) FileDelete(@ScriptDir & "\7za.exe") FileDelete(@ScriptDir & "\7za.dll") FileDelete(@ScriptDir & "\7zxa.dll") EndFunc #include "Zip.au3" Func ExtractZip($sFilePath) Logging("Extracting zip file: "&$sFilePath) $iReturn = _Zip_UnzipAll($sFilePath, RemoveExtRegExp($sFilePath), 1) Logging("The return code from zip code was: " & $iReturn) EndFunc Func RemoveExtRegExp($Input) Return StringRegExpReplace($Input, "\.[^.]*$", "") EndFunc Func RemoveExt($sFilePath,$sExt=".zip") Local $sDrive = "", $sDir = "", $sFileName = "", $sExtension = "" Local $aPathSplit = _PathSplit($sFilePath, $sDrive, $sDir, $sFileName, $sExtension) ;_ArrayDisplay($aPathSplit, "_PathSplit of " & @ScriptFullPath) if StringLower($sExtension) = $sExt Then return $sFileName Else return $sFilePath EndIf EndFunc