--%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --%%% %%% --%%% This script tests for the presence of Microsoft Visual C++ 2008 %%% --%%% %%% --%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --------------------------------------Códigos Externos---------------------------------------- function AddBS( cPath ) String.TrimRight(cPath,nil); if String.Length(cPath) > 0 and String.Right(cPath,1) ~= "\\" then cPath = cPath .. "\\" end return cPath end -- 64Bit Registry Support by jAssing -- support@jAssing.com -- This 'fixes' issues with the registry on 64bit machines -- all functions are the same, so you can use the intelisense -- and then change Registry. to Registry64. -- this is not a complete "replacement" set yet. -- On 32bit machines, it uses the default actions so it doesn't slow that down. -- This uses code by Brett -- http://www.indigorose.com/forums/showthread.php?t=9277 -- as well as code by Eagle -- he's posted it many places, and is included in the zip file here. function RegEdit( nHive, cKey, cValue, xData, nType) if System.Is64BitOS() then Debug.Print("RegEdit\r\n"); local cParam = " /f"; if type(cValue) == "string" then local cVP = " /v "..cValue ; if type(xData)=="string" and String.Find( xData, " ")>0 then xData = "\"" .. xData .. "\""; end if String.Length(cValue) == 0 then cVP = " /ve "; end cParam = cParam .. cVP .. " /t "..RegGetType( nType ) .. " /d "..xData; end RunReg( nHive, "add", cKey, cParam ) else if type(cValue) == "string" then Registry.SetValue( nHive, cKey, cValue, xData, nType); else Registry.CreateKey( nHive, cKey ); end end end function RegDelete(nHive, cKey, cValue) if System.Is64BitOS() then local cParam =" /f"; Debug.Print("RegDelete\r\n"); if type(cValue) == "string" then if String.Length(cValue) == 0 then cParam = cParam .. " /ve"; else cParam = " /v "..cValue .. cParam; end end RunReg( nHive, "delete", cKey, cParam); else if type(cValue) == "string" then Registry.DeleteValue( nHive, cKey, cValue ); else Registry.DeleteKey( nHive, cKey ); end end end function RegGetValueNames( nHive, cKey ) local tValues = {}; if System.Is64BitOS() then local cTemp = File.TempFileName(); Debug.Print("RegGetValueNames\r\n"); if RunReg( nHive, "query", cKey, "",cTemp) ==0 then local tFile = RegReadToTable( cTemp ); if tFile and type(tFile)=="table" then local x = 0; for x = 1, Table.Count( tFile ) do if String.Left( tFile[x], 4 ) == String.Repeat(' ',4) then local nTab = String.Find( tFile[x], "\t"); if nTab > 0 then local cValue = String.Mid( tFile[x], 5, nTab-5); if cValue == "" then cValue = "(Default)"; end Table.Insert(tValues, Table.Count( tValues) + 1, cValue); end end end else -- Not a table, no values -- empty default Table.Insert(tValues, 1, "(Default)"); end else RegDeleteFile(cTemp); end if Table.Count( tValues ) == 0 then tValues = nil; end else tValues = Registry.GetValueNames(nHive, cKey); end return tValues; end function RegGetKeyNames( nHive, cKey ) local tNames = {}; if System.Is64BitOS() then local cTemp = File.TempFileName(); Debug.Print("RegGetKeyNames\r\n"); if RunReg( nHive, "query", cKey, "",cTemp) ==0 then local tFile = RegReadToTable( cTemp ); if tFile and type(tFile) == "table" then local x = 0; for x = 1, Table.Count( tFile ) do if String.Find( tFile[x], cKey.."\\",1,false) > 0 then local cSubKey = String.Right( tFile[x], (String.Length(tFile[x])-String.ReverseFind( tFile[x], "\\"))); Table.Insert(tNames, Table.Count( tNames) + 1, cSubKey); end end end else RegDeleteFile(cTemp); end if Table.Count( tNames ) == 0 then tNames = nil; end else tNames = Registry.GetKeyNames(nHive, cKey); end return tNames; end function RegGetValueType( nHive, cKey, cValue ) local nType = -1; if System.Is64BitOS() then local cTemp = File.TempFileName(); Debug.Print("RegGetValueType\r\n"); if RunReg( nHive, "query", cKey," /v "..cValue,cTemp) ==0 then local tFile = RegReadToTable( cTemp ); local cLine = tFile[5]; local nTab = String.Find( cLine, "\t", 1, false); if nTab ~= -1 then local nTab2 = String.Find( cLine, "\t", nTab+1, false); if nTab2 ~= 1 then local cType = String.Mid( cLine, nTab+1, nTab2-nTab-1 ); nType = RegGetType( cType ); end end else RegDeleteFile(cTemp); end else nType = Registry.GetValueType(nHive, cKey, cValue); end return nType; end function RegGetValue( nHive, cKey, cValue, bExpand ) local cData = nil; local nErr = 1; local nReturn = -1; if System.Is64BitOS() then local cTemp = File.TempFileName(); Debug.Print("RegGetValue\r\n"); if String.Length(cValue) == 0 then nReturn = RunReg( nHive, "query", cKey, " /ve",cTemp); else nReturn = RunReg( nHive, "query", cKey, " /v "..cValue,cTemp); end if nReturn == 0 then local tFile = RegReadToTable( cTemp ); local cLine = tFile[5]; local nTab = String.Find( cLine, "\t", 1, false); if nTab ~= -1 then nTab = String.Find( cLine, "\t", nTab+1, false); if nTab ~= 1 then cData = String.Mid( cLine, nTab+1, String.Length(cLine) ); cData = RegStrTran(cData,"\\0", "|"); nErr = 0; end end else RegDeleteFile(cTemp); end else if type(bExpand) ~= "boolean" then bExpand = false; end cData = Registry.GetValue(nHive, cKey, cValue, bExpand); nErr = Application.GetLastError(); end if type(cData) ~= "string" then cData = ""; nErr = 1; end Application.SetLastError(nErr); return cData; end function RegDoesKeyExist( nHive, cKey ) local bIsThere = false; if System.Is64BitOS() then Debug.Print("RegDoesKeyExist"); bIsThere = (RunReg( nHive, "query", cKey, " /ve" ) == 0); else bIsThere = Registry.DoesKeyExist( nHive, cKey); end return bIsThere; end function RegReadToTable( cFile ) local tData = nil; if File.DoesExist( cFile ) then tData = TextFile.ReadToTable( cFile ); RegDeleteFile(cFile); if tData and type(tData)=="table" and Table.Count(tData) > 3 then if tData[2] == "! REG.EXE VERSION 3.0" then -- Do nothing; this is the 'standard' format for these tools are based else -- Here's where we deal with 'no version' local cVersion = File.GetVersionInfo( _SystemFolder .. "\\reg.exe" ).FileVersion; local nDot = String.Find( cVersion, '.'); if nDot > 0 then cVersion = String.Left( cVersion, nDot - 1); end Table.Insert( tData, 1, " "); Table.Insert( tData, 2, "! REG.EXE VERSION "..cVersion); local x = 0; for x = 1, Table.Count( tData ) do tData[x] = RegStrTran( tData[x], String.Repeat(' ',4), "\t", false); if String.Left(tData[x],1)=="\t" then tData[x] = String.Repeat(' ',4) .. String.Mid( tData[x],2, String.Length( tData[x] ) ); end local nRegBinary = String.Find( tData[x], "REG_BINARY"); if nRegBinary > 0 then -- we need to 'fix' to be properly spaced. local cBinVal = String.Mid( tData[x], nRegBinary+11, String.Length(tData[x]) ); local cNewVal = ""; -- Now let's space out the regbinary value local j=0; for j=1, String.Length( cBinVal ), 2 do cNewVal = cNewVal..String.Mid( cBinVal, j, 2) .. " "; end if String.Length( cNewVal ) ~= Math.Floor( String.Length(cNewVal)/2) then -- Needs to be ## ## ## ## so we need to add a zero cNewVal = '0'..cNewVal; end tData[x] = RegStrTran( tData[x], cBinVal, cNewVal); end local nDWord = String.Find( tData[x], "REG_DWORD"); if nDWord > 0 then local cOldVal = String.Mid( tData[x], nDWord+10, String.Length( tData[x] ) ); if String.Length(cOldVal) > 0 then local cNewVal = RegHexToNum( cOldVal ); tData[x] = RegStrTran( tData[x], cOldVal, cNewVal); end end end end assert( String.Left( tData[2], 1) == "!", "Unknown Reg output "..cFile); assert( Table.Count(tData)>=5, "Bad Table"); else Debug.Print("Table Invalid -- no values to list"); end end return tData end -- Support Functions function RegGetHive( nHive ) local cHive = ""; local tHive = { "HKCR", "HKCC", "HKCU", "HKLM", "HKU"}; nHive = nHive + 1; if nHive > 0 and nHive <= Table.Count( tHive ) then cHive = tHive[nHive]; end return cHive; end function RegGetType( xFindType ) local tTypes = {"REG_NONE", "REG_SZ", "REG_EXPAND_SZ", "REG_BINARY", "REG_DWORD", "REG_DWORD_LITTLE_ENDIAN", "REG_DWORD_BIG_ENDIAN", "REG_LINK", "REG_MULTI_SZ", "REG_RESOURCE_LIST", "REG_FULL_RESOURCE_DESCRIPTOR", "REG_RESOURCE_REQUIREMENTS_LIST"}; local xFoundType = nil; local x = 0; if type(xFindType) == "string" then for x=1, Table.Count( tTypes ) do if xFindType == tTypes[x] then xFoundType = x-1; x=Table.Count(tTypes); end end else xFoundType = tTypes[ xFindType+1 ]; end return xFoundType; end function RunReg( nHive, cCMD, cLine, cXtra, cOutput ) local cParam = RegGetHive(nHive); local nResult = -1; cParam = AddBS( cParam ) .. cLine; if String.Find( cParam, " ") > 0 then cParam = "\"" .. cParam .. "\""; end if type(cXtra)=="string" then cParam = cParam .. cXtra; end assert( File.DoesExist( _SystemFolder .. "\\reg.exe" ), "Missing Reg.exe"); if cOutput then assert( File.DoesExist( _SystemFolder .. "\\cmd.exe" ), "Missing cmd.exe"); DisableWow64ReDirect(); Debug.Print("Running Command: Reg.exe "..cCMD .." "..cParam.." >"..cOutput.."\r\n"); nResult = File.Run(_SystemFolder.."\\cmd.exe","/c ".._SystemFolder.."\\Reg.exe "..cCMD .." "..cParam.." >"..cOutput,_SystemFolder, -1, true); EnableWow64ReDirect(); RegDeleteFile(cBatchFile); else DisableWow64ReDirect(); Debug.Print("Running Reg.exe "..cCMD .. " "..cParam.."\r\n"); nResult = File.Run(_SystemFolder.."\\Reg.exe", cCMD .. " "..cParam, _SystemFolder, -1, true); EnableWow64ReDirect(); end Application.SetLastError(nResult); Debug.Print("Returning "..nResult.."\r\n"); return nResult; end function RegDeleteFile( cFile ) if type(cFile) == "string" and File.DoesExist( cFile ) then File.Delete( cFile,false,false,false,RegNoCallBack ); if File.DoesExist( cFile ) then File.DeleteOnReboot( cFile ); end end end function RegNoCallBack() return true; end function RegHexToNum( cNum ) local nReturn = cNum; if type(nReturn) == "string" then nReturn = String.TrimLeft( String.TrimRight( nReturn )); if String.CompareNoCase(String.Left(nReturn,2), "0x") == 0 then nReturn = String.Mid( nReturn, 3, String.Length( nReturn ) -2); nReturn = Math.HexToNumber( nReturn ); end end return nReturn; end function RegStrTran( cString, cFind, cNew, bCaseSpecific ) local cNewString = cString; if type(bCaseSpecific) ~= "boolean" then bCaseSpecific = true; end if type(cFind)=="string" and type(cString)=="string" and String.Length(cString) > 0 and String.Length(cFind) > 0 and cString ~= cFind then local nFind = String.Find( cString, cFind, 1, bCaseSpecific ); local nLastFind = -1; -- prevent endless loops while nFind > 0 and nFind ~= nLastFind do local cTemp = String.Left( cNewString, nFind-1 ); cTemp = cTemp .. cNew; cTemp = cTemp .. String.Mid( cNewString, nFind+String.Length(cFind), String.Length(cNewString)); cNewString = cTemp; nLastFind = nFind; nFind = String.Find( cNewString, cFind, 1, bCaseSpecific ); end end return cNewString; end function RegGetTempFileName( cExtension ) -- This uses 'random' code by Brett, see post http://www.indigorose.com/forums/showthread.php?t=9277 local cFile = ""; if not cExtension then cExtension = "tmp"; end repeat cFile = _TempFolder.."\\"..String.RandomFromPattern("r64?????."..cExtension); until not File.DoesExist( cFile ); return cFile end -- Object Creation Registry64={}; Registry64.CreateKey = RegEdit; Registry64.DeleteKey = RegDelete; Registry64.DeleteValue = RegDelete; Registry64.DoesKeyExist = RegDoesKeyExist; -- Registry64.GetAccess = ?? Registry64.GetKeyNames = RegGetKeyNames; Registry64.GetValue = RegGetValue; Registry64.GetValueNames= RegGetValueNames; Registry64.GetValueType = RegGetValueType; Registry64.SetValue = RegEdit; File.TempFileName = RegGetTempFileName; -- The following wow64 code is by Eagle -- look thru the IR forums -- it's posted all over the place. -- Modified by jAssing --sWOW64 DIS-EN function DisableWow64ReDirect() if System.Is64BitOS() and (not bWow64Disabled) then --Debug.Print("Disabling Wow64 Redirect\r\n"); DLL.CallFunction(_WindowsFolder.."\\SysWOW64\\kernel32.dll", "Wow64DisableWow64FsRedirection", "\""..Application.GetWndHandle().."\"", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL); Application.Sleep(50); bWow64Disabled = true; end end function EnableWow64ReDirect() if System.Is64BitOS() and bWow64Disabled then --Debug.Print("Enabling Wow64 Redirect\r\n"); DLL.CallFunction(_WindowsFolder.."\\SysWOW64\\kernel32.dll", "Wow64RevertWow64FsRedirection", "\""..Application.GetWndHandle().."\"" , DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL); Application.Sleep(50); bWow64Disabled = nil; end end --eWOW64 DIS-EN --[[ FUNCITON: String.RandomFromPattern PURPOSE: To return a random string based on a given pattern. PARAMETERS: Pattern (string) - The pattern to base the random string on. Interpreted as follows: # - A random digit (0-9) * - A random uppercase letter (A-Z) @ - A random lowercase letter (a-z) ? - A random digit or uppercase letter (0-9,A-Z) ~ - A random digit, upppercase or lowercase letter (0-9,A-Z,a-z) Any other charater - Remains the same. RETURNS: A randomized string. EXAMPLES: String.RandomFromPattern("###-###"); -- could produce: "6355-0989" String.RandomFromPattern("TEST-***"); -- could produce: "TEST-HAJ" String.RandomFromPattern("~~~~~~~~~~"); -- could produce: "7Hg543fp02" ]] function String.RandomFromPattern(Pattern) local strReturn = ""; local tblAlphabet = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N", "O","P","Q","R","S","T","U","V","W","X","Y","Z"}; -- Seed the random number engine with the current time... local nRandomSeed = 0; nRandomSeed = String.ToNumber(System.GetTime(TIME_FMT_HOUR)); nRandomSeed = nRandomSeed * String.ToNumber(System.GetTime(TIME_FMT_MIN)); nRandomSeed = nRandomSeed * String.ToNumber(System.GetTime(TIME_FMT_SEC)); Math.RandomSeed(nRandomSeed); local nStringLength = String.Length(Pattern); for i = 1,nStringLength do local nChar = String.Mid(Pattern,i,1); if(nChar == "#")then -- Number nChar = Math.Random(0,9); elseif(nChar == "*")then -- Uppercase letter nChar = tblAlphabet[Math.Random(1,26)]; elseif(nChar == "@")then -- Lowercase letter nChar = String.Lower(tblAlphabet[Math.Random(1,26)]); elseif(nChar == "?")then -- Number or Uppercase letter local nCoinToss = Math.Random(1,2); if(nCoinToss == 1)then -- Number nChar = Math.Random(0,9); else -- Uppercase Letter nChar = tblAlphabet[Math.Random(1,26)]; end elseif(nChar == "~")then -- Number or Uppercase letter or Lowercase Letter local nCoinToss = Math.Random(1,3); if(nCoinToss == 1)then -- Number nChar = Math.Random(0,9); elseif(nCoinToss == 2)then -- Uppercase Letter nChar = tblAlphabet[Math.Random(1,26)]; else -- Lowercase letter nChar = String.Lower(tblAlphabet[Math.Random(1,26)]); end end strReturn = strReturn..nChar; end return strReturn; end ---------------------------------------------Mi Código------------------------------------------- function VCpp2008Runtime_ver() local b64BitOs = System.Is64BitOS(); local searchFolder = {}; if(b64BitOs) then searchFolder[1] = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{350AA351-21FA-3270-8B7A-835434E766AD}" searchFolder[2] = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{8220EEFE-38CD-377E-8595-13398D740ACE}" searchFolder[3] = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{4B6C7001-C7D6-3710-913E-5BC23FCE91E6}" else searchFolder[1] = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{FF66E9F6-83E7-3A3E-AF14-8DE9A809A6A4}" searchFolder[2] = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{9A25302D-30C0-39D9-BD6F-21E6EC160475}" searchFolder[3] = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{1F1C2DFC-2D24-3E06-BCB8-725134ADF989}" end for j = 1, 3 do --encontrado = Registry.GetValue(HKEY_LOCAL_MACHINE, searchFolder[j], "DisplayVersion", true); encontrado = RegGetValue(HKEY_LOCAL_MACHINE, searchFolder[j], "DisplayVersion", true) if encontrado ~= "" then return encontrado; end end return "0.0.00000.0"; end