rm4453 Posted March 20, 2019 Share Posted March 20, 2019 (edited) 12 minutes ago, AasimPathan said: I created the file and entered 1.0.2.2 now i get VER=1.0.2.2 twice Then the error: "C:\Users\username\Desktop\MSIGetVer.au3" (23) : ==> The requested action with this object has failed.: $oPropValue = $oRecords.StringData(2) $oPropValue = $oRecords^ ERROR >Exit code: 1 Time: 25.45 how does this do for you ? (it will keep running until you manually close it FYI due to infinite while 1 loop) PUT A SAMPLE .MSI FILE IN THE FOLDER AS TXT FILE!!! expandcollapse popup#include <AutoItConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> $user = "DomainAdmin" $pass = "Password" $domain = "Domain" ; this below script was taken from one of the forum posts I forgot who's it was but if I run into it again i'll give an honorable mention to the creator of the script ---------------------------------- LINK TO POST ------------------>>>>>>>>>>https://www.autoitscript.com/forum/topic/166521-read-msi-data-programatically-with-autoit/ ;.msiGetMSIDetails() If FileExists("C:\Program Files\MatrixCodebase\MatrixCodebase.msi") Then $sMSI = "C:\Program Files\MatrixCodebase\MatrixCodebase.msi" ElseIf FileExists("C:\Program Files (x86)\MatrixCodebase\MatrixCodebase.msi") Then ;here i would like to specify a path rather than for it to get me a dialog box to browse the msi file. $sMSI = "C:\Program Files (x86)\MatrixCodebase\MatrixCodebase.msi" EndIf While 1 Sleep(25) $lVars = CheckInfo($sMSI) ; get the version infos for the local MSI $rVars = CheckInfo("A:\U_A\U_W\C_NonFiledFiles\MatrixCodebase.msi") ; get the version infos for the remote MSI If $iVars[0] = $rVars[0] And $iVars[1] <> $rVars[1] Then DeployNewVer() EndIf EndIf Func DeployNewVer() Local $DisplayMsgBox = MsgBox($MB_YESNO, "Release components", "****Some Text***** Do you want to deploy? Press 'Yes' to Continue, Or press 'No' to Exit") Select Case $DisplayMsgBox = 6 ;Yes CloseRunningOfficePrograms() Sleep(1000) ;UninstallMatrixCodeBase() Sleep(1000) ;InstallMatrixCodeBase() Case $DisplayMsgBox = 7 ;No Exit EndSelect EndFunc ;==>DeployNewVer Func CloseRunningOfficePrograms() If ProcessExists("WINWORD.EXE") Then ProcessClose("WINWORD.EXE") If ProcessExists("EXCEL.EXE") Then ProcessClose("EXCEL.EXE") If ProcessExists("OUTLOOK.EXE") Then ProcessClose("OUTLOOK.EXE") If ProcessExists("VISIO.EXE") Then ProcessClose("VISIO.EXE") If ProcessExists("POWERPNT.EXE") Then ProcessClose("POWERPNT.EXE") EndFunc ;==>CloseRunningOfficePrograms Func InstallMatrixCodeBase() FileCopy("*\*\MatrixCodeBase.msi", "C:\Install") RunAsWait($user, $domain, $pass, 0, "msiexec /i C:\Install\MatrixCodeBase.msi /passive") FileDelete("*\*\MatrixCodeBase.msi") EndFunc ;==>InstallMatrixCodeBase Func CheckInfo($sMSI) $oInstaller = ObjCreate("WindowsInstaller.Installer") $oDB = $oInstaller.OpenDataBase($sMSI, 0) $oView = $oDB.OpenView("SELECT Property,Value FROM Property") $oView.Execute() $oCount = 0 $pName = "" $pVer = 0 While @error = 0 $oRecords = $oView.Fetch $oPropValue = $oRecords.StringData(2) $oPropName = $oRecords.StringData(1) If $oPropName <> "" Then $oCount += 1 ConsoleWrite($oPropName & " = " & $oPropValue & @CRLF) If $oPropName = "ProductName" Then $pName = $oPropValue EndIf If $oPropName = "ProductVersion" Then $pVer = $oPropValue EndIf If $pName <> "" And $pVer <> 0 Then $pVals[2] = [$pName, $pVer] Return $pVals EndIf EndIf WEnd ; The only thing I want the above to get is Product Name & Product Version. Product name to only match if its our software file name (e.g. MatrixCodebase.msi) and Production Version so that the version is greater than say e.g. 1.0.3.0 so if i place a new file in there and its version is 1.0.4.0 then it will run the rest of the script if not it will exit EndFunc ;==>CheckInfo Edited March 20, 2019 by rm4453 CODE UPDATED BONKED THE REMOTE FILE PATH - FIXED Link to comment Share on other sites More sharing options...
AasimPathan Posted March 20, 2019 Author Share Posted March 20, 2019 ==> Expected a "=" operator in assignment statement.: $pVals[2] = [$pName, $pVer] $pVals^ ERROR Link to comment Share on other sites More sharing options...
rm4453 Posted March 20, 2019 Share Posted March 20, 2019 4 minutes ago, AasimPathan said: ==> Expected a "=" operator in assignment statement.: $pVals[2] = [$pName, $pVer] $pVals^ ERROR Try code below: expandcollapse popup#include <AutoItConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> $user = "DomainAdmin" $pass = "Password" $domain = "Domain" ; this below script was taken from one of the forum posts I forgot who's it was but if I run into it again i'll give an honorable mention to the creator of the script ---------------------------------- LINK TO POST ------------------>>>>>>>>>>https://www.autoitscript.com/forum/topic/166521-read-msi-data-programatically-with-autoit/ ;.msiGetMSIDetails() If FileExists("C:\Program Files\MatrixCodebase\MatrixCodebase.msi") Then $sMSI = "C:\Program Files\MatrixCodebase\MatrixCodebase.msi" ElseIf FileExists("C:\Program Files (x86)\MatrixCodebase\MatrixCodebase.msi") Then ;here i would like to specify a path rather than for it to get me a dialog box to browse the msi file. $sMSI = "C:\Program Files (x86)\MatrixCodebase\MatrixCodebase.msi" EndIf While 1 Sleep(25) $lVars = CheckInfo($sMSI) ; get the version infos for the local MSI $rVars = CheckInfo("A:\U_A\U_W\C_NonFiledFiles\MatrixCodebase.msi") ; get the version infos for the remote MSI If $iVars[0] = $rVars[0] And $iVars[1] <> $rVars[1] Then DeployNewVer() EndIf EndIf Func DeployNewVer() Local $DisplayMsgBox = MsgBox($MB_YESNO, "Release components", "****Some Text***** Do you want to deploy? Press 'Yes' to Continue, Or press 'No' to Exit") Select Case $DisplayMsgBox = 6 ;Yes CloseRunningOfficePrograms() Sleep(1000) ;UninstallMatrixCodeBase() Sleep(1000) ;InstallMatrixCodeBase() Case $DisplayMsgBox = 7 ;No Exit EndSelect EndFunc ;==>DeployNewVer Func CloseRunningOfficePrograms() If ProcessExists("WINWORD.EXE") Then ProcessClose("WINWORD.EXE") If ProcessExists("EXCEL.EXE") Then ProcessClose("EXCEL.EXE") If ProcessExists("OUTLOOK.EXE") Then ProcessClose("OUTLOOK.EXE") If ProcessExists("VISIO.EXE") Then ProcessClose("VISIO.EXE") If ProcessExists("POWERPNT.EXE") Then ProcessClose("POWERPNT.EXE") EndFunc ;==>CloseRunningOfficePrograms Func InstallMatrixCodeBase() FileCopy("*\*\MatrixCodeBase.msi", "C:\Install") RunAsWait($user, $domain, $pass, 0, "msiexec /i C:\Install\MatrixCodeBase.msi /passive") FileDelete("*\*\MatrixCodeBase.msi") EndFunc ;==>InstallMatrixCodeBase Func CheckInfo($sMSI) $oInstaller = ObjCreate("WindowsInstaller.Installer") $oDB = $oInstaller.OpenDataBase($sMSI, 0) $oView = $oDB.OpenView("SELECT Property,Value FROM Property") $oView.Execute() $oCount = 0 $pName = "" $pVer = 0 While @error = 0 $oRecords = $oView.Fetch $oPropValue = $oRecords.StringData(2) $oPropName = $oRecords.StringData(1) If $oPropName <> "" Then $oCount += 1 ConsoleWrite($oPropName & " = " & $oPropValue & @CRLF) If $oPropName = "ProductName" Then $pName = $oPropValue EndIf If $oPropName = "ProductVersion" Then $pVer = $oPropValue EndIf If $pName <> "" And $pVer <> 0 Then Local $pVals[2] = [$pName, $pVer] Return $pVals EndIf EndIf WEnd ; The only thing I want the above to get is Product Name & Product Version. Product name to only match if its our software file name (e.g. MatrixCodebase.msi) and Production Version so that the version is greater than say e.g. 1.0.3.0 so if i place a new file in there and its version is 1.0.4.0 then it will run the rest of the script if not it will exit EndFunc ;==>CheckInfo Link to comment Share on other sites More sharing options...
AasimPathan Posted March 20, 2019 Author Share Posted March 20, 2019 ==> Variable used without being declared.: If $iVars[0] = $rVars[0] And $iVars[1] <> $rVars[1] Then If ^ ERROR Link to comment Share on other sites More sharing options...
AasimPathan Posted March 20, 2019 Author Share Posted March 20, 2019 Just now, AasimPathan said: ==> Variable used without being declared.: If $iVars[0] = $rVars[0] And $iVars[1] <> $rVars[1] Then If ^ ERROR you declared $iVars = CheckInfo instead of $lVars = CheckInfo hence the error Link to comment Share on other sites More sharing options...
rm4453 Posted March 20, 2019 Share Posted March 20, 2019 Just now, AasimPathan said: you declared $iVars = CheckInfo instead of $lVars = CheckInfo hence the error expandcollapse popup#include <AutoItConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> $user = "DomainAdmin" $pass = "Password" $domain = "Domain" ; this below script was taken from one of the forum posts I forgot who's it was but if I run into it again i'll give an honorable mention to the creator of the script ---------------------------------- LINK TO POST ------------------>>>>>>>>>>https://www.autoitscript.com/forum/topic/166521-read-msi-data-programatically-with-autoit/ ;.msiGetMSIDetails() If FileExists("C:\Program Files\MatrixCodebase\MatrixCodebase.msi") Then $sMSI = "C:\Program Files\MatrixCodebase\MatrixCodebase.msi" ElseIf FileExists("C:\Program Files (x86)\MatrixCodebase\MatrixCodebase.msi") Then ;here i would like to specify a path rather than for it to get me a dialog box to browse the msi file. $sMSI = "C:\Program Files (x86)\MatrixCodebase\MatrixCodebase.msi" EndIf While 1 Sleep(25) $lVars[2] = CheckInfo($sMSI) ; get the version infos for the local MSI $rVars[2] = CheckInfo("A:\U_A\U_W\C_NonFiledFiles\MatrixCodebase.msi") ; get the version infos for the remote MSI If $lVars[0] = $rVars[0] And $lVars[1] <> $rVars[1] Then DeployNewVer() EndIf EndIf Func DeployNewVer() Local $DisplayMsgBox = MsgBox($MB_YESNO, "Release components", "****Some Text***** Do you want to deploy? Press 'Yes' to Continue, Or press 'No' to Exit") Select Case $DisplayMsgBox = 6 ;Yes CloseRunningOfficePrograms() Sleep(1000) ;UninstallMatrixCodeBase() Sleep(1000) ;InstallMatrixCodeBase() Case $DisplayMsgBox = 7 ;No Exit EndSelect EndFunc ;==>DeployNewVer Func CloseRunningOfficePrograms() If ProcessExists("WINWORD.EXE") Then ProcessClose("WINWORD.EXE") If ProcessExists("EXCEL.EXE") Then ProcessClose("EXCEL.EXE") If ProcessExists("OUTLOOK.EXE") Then ProcessClose("OUTLOOK.EXE") If ProcessExists("VISIO.EXE") Then ProcessClose("VISIO.EXE") If ProcessExists("POWERPNT.EXE") Then ProcessClose("POWERPNT.EXE") EndFunc ;==>CloseRunningOfficePrograms Func InstallMatrixCodeBase() FileCopy("*\*\MatrixCodeBase.msi", "C:\Install") RunAsWait($user, $domain, $pass, 0, "msiexec /i C:\Install\MatrixCodeBase.msi /passive") FileDelete("*\*\MatrixCodeBase.msi") EndFunc ;==>InstallMatrixCodeBase Func CheckInfo($sMSI) $oInstaller = ObjCreate("WindowsInstaller.Installer") $oDB = $oInstaller.OpenDataBase($sMSI, 0) $oView = $oDB.OpenView("SELECT Property,Value FROM Property") $oView.Execute() $oCount = 0 $pName = "" $pVer = 0 While @error = 0 $oRecords = $oView.Fetch $oPropValue = $oRecords.StringData(2) $oPropName = $oRecords.StringData(1) If $oPropName <> "" Then $oCount += 1 ConsoleWrite($oPropName & " = " & $oPropValue & @CRLF) If $oPropName = "ProductName" Then $pName = $oPropValue EndIf If $oPropName = "ProductVersion" Then $pVer = $oPropValue EndIf If $pName <> "" And $pVer <> 0 Then Local $pVals[2] = [$pName, $pVer] Return $pVals EndIf EndIf WEnd ; The only thing I want the above to get is Product Name & Product Version. Product name to only match if its our software file name (e.g. MatrixCodebase.msi) and Production Version so that the version is greater than say e.g. 1.0.3.0 so if i place a new file in there and its version is 1.0.4.0 then it will run the rest of the script if not it will exit EndFunc ;==>CheckInfo Link to comment Share on other sites More sharing options...
AasimPathan Posted March 20, 2019 Author Share Posted March 20, 2019 Now it fails to end or respond ProductVersion = 1.0.3.0 >Process failed to respond; forcing abrupt termination... >Exit code: 1 Time: 74.05 Link to comment Share on other sites More sharing options...
rm4453 Posted March 20, 2019 Share Posted March 20, 2019 Just now, AasimPathan said: Now it fails to end or respond ProductVersion = 1.0.3.0 >Process failed to respond; forcing abrupt termination... >Exit code: 1 Time: 74.05 can you please give full console out put as well as make sure the .msi file paths are correct? *minimal context makes it hard to find the bug esp when i can't recreate your issue / system layout* Link to comment Share on other sites More sharing options...
AasimPathan Posted March 20, 2019 Author Share Posted March 20, 2019 expandcollapse popup#include <AutoItConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> If FileExists("A:\U_A\U_W\U_Dpts\U_IT\U_Soft\C\U_Core\U_BayVL00\U_ReleaseMSIPackages\U_A_Core\U_Current\U_Source\bin\Release\MatrixCodeBase.msi") Then $sMSI = "A:\U_A\U_W\U_Dpts\U_IT\U_Soft\C\U_Core\U_BayVL00\U_ReleaseMSIPackages\U_A_Core\U_Current\U_Source\bin\Release\MatrixCodeBase.msi" EndIf While 1 Sleep(25) $lVars = CheckInfo($sMSI) ; get the version infos for the local MSI $rVars = CheckInfo("A:\U_A\U_W\U_Dpts\U_IT\U_Soft\C\U_Core\U_BayVL00\U_ReleaseMSIPackages\U_A_Core\U_Current\U_Source\bin\Release\MatrixCodeBase.msi") ; get the version infos for the remote MSI If $lVars[0] = $rVars[0] And $lVars[1] <> $rVars[1] Then DeployNewVer() EndIf WEnd Func DeployNewVer() Local $DisplayMsgBox = MsgBox($MB_YESNO, "Release components", "****Some Text***** Do you want to deploy? Press 'Yes' to Continue, Or press 'No' to Exit") Select Case $DisplayMsgBox = 6 ;Yes CloseRunningOfficePrograms() Sleep(1000) ;UninstallMatrixCodeBase() Sleep(1000) ;InstallMatrixCodeBase() Case $DisplayMsgBox = 7 ;No Exit EndSelect EndFunc ;==>DeployNewVer Func CloseRunningOfficePrograms() If ProcessExists("WINWORD.EXE") Then ProcessClose("WINWORD.EXE") If ProcessExists("EXCEL.EXE") Then ProcessClose("EXCEL.EXE") If ProcessExists("OUTLOOK.EXE") Then ProcessClose("OUTLOOK.EXE") If ProcessExists("VISIO.EXE") Then ProcessClose("VISIO.EXE") If ProcessExists("POWERPNT.EXE") Then ProcessClose("POWERPNT.EXE") EndFunc Func CheckInfo($sMSI) $oInstaller = ObjCreate("WindowsInstaller.Installer") $oDB = $oInstaller.OpenDataBase($sMSI, 0) $oView = $oDB.OpenView("SELECT Property,Value FROM Property") $oView.Execute() $oCount = 0 $pName = "" $pVer = 0 While @error = 0 $oRecords = $oView.Fetch $oPropValue = $oRecords.StringData(2) $oPropName = $oRecords.StringData(1) If $oPropName <> "" Then $oCount += 1 ConsoleWrite($oPropName & " = " & $oPropValue & @CRLF) If $oPropName = "ProductName" Then $pName = $oPropValue EndIf If $oPropName = "ProductVersion" Then $pVer = $oPropValue EndIf If $pName <> "" And $pVer <> 0 Then Local $pVals[2] = [$pName, $pVer] Return $pVals EndIf EndIf WEnd EndFunc ;==>CheckInfo Here is the full context of the script The script continues to loop expandcollapse popup>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\PathA00\Desktop\NewMSIInfo.au3" UpgradeCode = {050884C0-CB1A-46D5-8CCD-B35574D6F79C} ALLUSERS = 1 Manufacturer = Company Name ProductCode = {8B3DFDFF-D894-4A31-AA92-824729385F15} ProductLanguage = 1033 ProductName = Matrix Code Base ProductVersion = 1.0.3.0 UpgradeCode = {050884C0-CB1A-46D5-8CCD-B35574D6F79C} ALLUSERS = 1 Manufacturer =Company Name ProductCode = {8B3DFDFF-D894-4A31-AA92-824729385F15} ProductLanguage = 1033 ProductName = Matrix Code Base ProductVersion = 1.0.3.0 UpgradeCode = {050884C0-CB1A-46D5-8CCD-B35574D6F79C} ALLUSERS = 1 Manufacturer = Company Name ProductCode = {8B3DFDFF-D894-4A31-AA92-824729385F15} ProductLanguage = 1033 ProductName = Matrix Code Base ProductVersion = 1.0.3.0 UpgradeCode = {050884C0-CB1A-46D5-8CCD-B35574D6F79C} ALLUSERS = 1 Manufacturer = Company Name ProductCode = {8B3DFDFF-D894-4A31-AA92-824729385F15} ProductLanguage = 1033 ProductName = Matrix Code Base ProductVersion = 1.0.3.0 UpgradeCode = {050884C0-CB1A-46D5-8CCD-B35574D6F79C} ALLUSERS = 1 Manufacturer = Company Name ProductCode = {8B3DFDFF-D894-4A31-AA92-824729385F15} ProductLanguage = 1033 ProductName = Matrix Code Base ProductVersion = 1.0.3.0 UpgradeCode = {050884C0-CB1A-46D5-8CCD-B35574D6F79C} ALLUSERS = 1 Manufacturer = Company Name ProductCode = {8B3DFDFF-D894-4A31-AA92-824729385F15} ProductLanguage = 1033 ProductName = Matrix Code Base ProductVersion = 1.0.3.0 UpgradeCode = {050884C0-CB1A-46D5-8CCD-B35574D6F79C} ALLUSERS = 1 Manufacturer = Company Name ProductCode = {8B3DFDFF-D894-4A31-AA92-824729385F15} ProductLanguage = 1033 ProductName = Matrix Code Base ProductVersion = 1.0.3.0 UpgradeCode = {050884C0-CB1A-46D5-8CCD-B35574D6F79C} ALLUSERS = 1 Manufacturer = Company Name ProductCode = {8B3DFDFF-D894-4A31-AA92-824729385F15} ProductLanguage = 1033 ProductName = Matrix Code Base ProductVersion = 1.0.3.0 UpgradeCode = {050884C0-CB1A-46D5-8CCD-B35574D6F79C} ALLUSERS = 1 Manufacturer = Company Name ProductCode = {8B3DFDFF-D894-4A31-AA92-824729385F15} ProductLanguage = 1033 ProductName = Matrix Code Base ProductVersion = 1.0.3.0 UpgradeCode = {050884C0-CB1A-46D5-8CCD-B35574D6F79C} ALLUSERS = 1 Manufacturer = Company Name ProductCode = {8B3DFDFF-D894-4A31-AA92-824729385F15} ProductLanguage = 1033 ProductName = Matrix Code Base ProductVersion = 1.0.3.0 >Process failed to respond; forcing abrupt termination... >Exit code: 1 Time: 5.982 Link to comment Share on other sites More sharing options...
rm4453 Posted March 20, 2019 Share Posted March 20, 2019 5 minutes ago, AasimPathan said: expandcollapse popup#include <AutoItConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> If FileExists("A:\U_A\U_W\U_Dpts\U_IT\U_Soft\C\U_Core\U_BayVL00\U_ReleaseMSIPackages\U_A_Core\U_Current\U_Source\bin\Release\MatrixCodeBase.msi") Then $sMSI = "A:\U_A\U_W\U_Dpts\U_IT\U_Soft\C\U_Core\U_BayVL00\U_ReleaseMSIPackages\U_A_Core\U_Current\U_Source\bin\Release\MatrixCodeBase.msi" EndIf While 1 Sleep(25) $lVars = CheckInfo($sMSI) ; get the version infos for the local MSI $rVars = CheckInfo("A:\U_A\U_W\U_Dpts\U_IT\U_Soft\C\U_Core\U_BayVL00\U_ReleaseMSIPackages\U_A_Core\U_Current\U_Source\bin\Release\MatrixCodeBase.msi") ; get the version infos for the remote MSI If $lVars[0] = $rVars[0] And $lVars[1] <> $rVars[1] Then DeployNewVer() EndIf WEnd Func DeployNewVer() Local $DisplayMsgBox = MsgBox($MB_YESNO, "Release components", "****Some Text***** Do you want to deploy? Press 'Yes' to Continue, Or press 'No' to Exit") Select Case $DisplayMsgBox = 6 ;Yes CloseRunningOfficePrograms() Sleep(1000) ;UninstallMatrixCodeBase() Sleep(1000) ;InstallMatrixCodeBase() Case $DisplayMsgBox = 7 ;No Exit EndSelect EndFunc ;==>DeployNewVer Func CloseRunningOfficePrograms() If ProcessExists("WINWORD.EXE") Then ProcessClose("WINWORD.EXE") If ProcessExists("EXCEL.EXE") Then ProcessClose("EXCEL.EXE") If ProcessExists("OUTLOOK.EXE") Then ProcessClose("OUTLOOK.EXE") If ProcessExists("VISIO.EXE") Then ProcessClose("VISIO.EXE") If ProcessExists("POWERPNT.EXE") Then ProcessClose("POWERPNT.EXE") EndFunc Func CheckInfo($sMSI) $oInstaller = ObjCreate("WindowsInstaller.Installer") $oDB = $oInstaller.OpenDataBase($sMSI, 0) $oView = $oDB.OpenView("SELECT Property,Value FROM Property") $oView.Execute() $oCount = 0 $pName = "" $pVer = 0 While @error = 0 $oRecords = $oView.Fetch $oPropValue = $oRecords.StringData(2) $oPropName = $oRecords.StringData(1) If $oPropName <> "" Then $oCount += 1 ConsoleWrite($oPropName & " = " & $oPropValue & @CRLF) If $oPropName = "ProductName" Then $pName = $oPropValue EndIf If $oPropName = "ProductVersion" Then $pVer = $oPropValue EndIf If $pName <> "" And $pVer <> 0 Then Local $pVals[2] = [$pName, $pVer] Return $pVals EndIf EndIf WEnd EndFunc ;==>CheckInfo Here is the full context of the script The script continues to loop expandcollapse popup>"C:\Program Files (x86)\AutoIt3\SciTE\..\autoit3.exe" /ErrorStdOut "C:\Users\PathA00\Desktop\NewMSIInfo.au3" UpgradeCode = {050884C0-CB1A-46D5-8CCD-B35574D6F79C} ALLUSERS = 1 Manufacturer = Company Name ProductCode = {8B3DFDFF-D894-4A31-AA92-824729385F15} ProductLanguage = 1033 ProductName = Matrix Code Base ProductVersion = 1.0.3.0 UpgradeCode = {050884C0-CB1A-46D5-8CCD-B35574D6F79C} ALLUSERS = 1 Manufacturer =Company Name ProductCode = {8B3DFDFF-D894-4A31-AA92-824729385F15} ProductLanguage = 1033 ProductName = Matrix Code Base ProductVersion = 1.0.3.0 UpgradeCode = {050884C0-CB1A-46D5-8CCD-B35574D6F79C} ALLUSERS = 1 Manufacturer = Company Name ProductCode = {8B3DFDFF-D894-4A31-AA92-824729385F15} ProductLanguage = 1033 ProductName = Matrix Code Base ProductVersion = 1.0.3.0 UpgradeCode = {050884C0-CB1A-46D5-8CCD-B35574D6F79C} ALLUSERS = 1 Manufacturer = Company Name ProductCode = {8B3DFDFF-D894-4A31-AA92-824729385F15} ProductLanguage = 1033 ProductName = Matrix Code Base ProductVersion = 1.0.3.0 UpgradeCode = {050884C0-CB1A-46D5-8CCD-B35574D6F79C} ALLUSERS = 1 Manufacturer = Company Name ProductCode = {8B3DFDFF-D894-4A31-AA92-824729385F15} ProductLanguage = 1033 ProductName = Matrix Code Base ProductVersion = 1.0.3.0 UpgradeCode = {050884C0-CB1A-46D5-8CCD-B35574D6F79C} ALLUSERS = 1 Manufacturer = Company Name ProductCode = {8B3DFDFF-D894-4A31-AA92-824729385F15} ProductLanguage = 1033 ProductName = Matrix Code Base ProductVersion = 1.0.3.0 UpgradeCode = {050884C0-CB1A-46D5-8CCD-B35574D6F79C} ALLUSERS = 1 Manufacturer = Company Name ProductCode = {8B3DFDFF-D894-4A31-AA92-824729385F15} ProductLanguage = 1033 ProductName = Matrix Code Base ProductVersion = 1.0.3.0 UpgradeCode = {050884C0-CB1A-46D5-8CCD-B35574D6F79C} ALLUSERS = 1 Manufacturer = Company Name ProductCode = {8B3DFDFF-D894-4A31-AA92-824729385F15} ProductLanguage = 1033 ProductName = Matrix Code Base ProductVersion = 1.0.3.0 UpgradeCode = {050884C0-CB1A-46D5-8CCD-B35574D6F79C} ALLUSERS = 1 Manufacturer = Company Name ProductCode = {8B3DFDFF-D894-4A31-AA92-824729385F15} ProductLanguage = 1033 ProductName = Matrix Code Base ProductVersion = 1.0.3.0 UpgradeCode = {050884C0-CB1A-46D5-8CCD-B35574D6F79C} ALLUSERS = 1 Manufacturer = Company Name ProductCode = {8B3DFDFF-D894-4A31-AA92-824729385F15} ProductLanguage = 1033 ProductName = Matrix Code Base ProductVersion = 1.0.3.0 >Process failed to respond; forcing abrupt termination... >Exit code: 1 Time: 5.982 It was supposed to loop like that so it would be able to run infinitely and auto-update whenever the versions are different, however, I made so it will exit if it runs the deploy updated version. Also, the line 6-8 is supposed to be the file path to the local version of the MSI expandcollapse popup#include <AutoItConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> If FileExists("A:\U_A\U_W\U_Dpts\U_IT\U_Soft\C\U_Core\U_BayVL00\U_ReleaseMSIPackages\U_A_Core\U_Current\U_Source\bin\Release\MatrixCodeBase.msi") Then $sMSI = "A:\U_A\U_W\U_Dpts\U_IT\U_Soft\C\U_Core\U_BayVL00\U_ReleaseMSIPackages\U_A_Core\U_Current\U_Source\bin\Release\MatrixCodeBase.msi" ; set the local version infos for the MSI EndIf While 1 Sleep(25) $lVars = CheckInfo($sMSI) ; get the version infos for the local MSI $rVars = CheckInfo("A:\U_A\U_W\U_Dpts\U_IT\U_Soft\C\U_Core\U_BayVL00\U_ReleaseMSIPackages\U_A_Core\U_Current\U_Source\bin\Release\MatrixCodeBase.msi") ; get the version infos for the remote MSI If $lVars[0] = $rVars[0] And $lVars[1] <> $rVars[1] Then DeployNewVer() Exit EndIf WEnd Func DeployNewVer() Local $DisplayMsgBox = MsgBox($MB_YESNO, "Release components", "****Some Text***** Do you want to deploy? Press 'Yes' to Continue, Or press 'No' to Exit") Select Case $DisplayMsgBox = 6 ;Yes CloseRunningOfficePrograms() Sleep(1000) ;UninstallMatrixCodeBase() Sleep(1000) ;InstallMatrixCodeBase() Case $DisplayMsgBox = 7 ;No Exit EndSelect EndFunc ;==>DeployNewVer Func CloseRunningOfficePrograms() If ProcessExists("WINWORD.EXE") Then ProcessClose("WINWORD.EXE") If ProcessExists("EXCEL.EXE") Then ProcessClose("EXCEL.EXE") If ProcessExists("OUTLOOK.EXE") Then ProcessClose("OUTLOOK.EXE") If ProcessExists("VISIO.EXE") Then ProcessClose("VISIO.EXE") If ProcessExists("POWERPNT.EXE") Then ProcessClose("POWERPNT.EXE") EndFunc Func CheckInfo($sMSI) $oInstaller = ObjCreate("WindowsInstaller.Installer") $oDB = $oInstaller.OpenDataBase($sMSI, 0) $oView = $oDB.OpenView("SELECT Property,Value FROM Property") $oView.Execute() $oCount = 0 $pName = "" $pVer = 0 While @error = 0 $oRecords = $oView.Fetch $oPropValue = $oRecords.StringData(2) $oPropName = $oRecords.StringData(1) If $oPropName <> "" Then $oCount += 1 ConsoleWrite($oPropName & " = " & $oPropValue & @CRLF) If $oPropName = "ProductName" Then $pName = $oPropValue EndIf If $oPropName = "ProductVersion" Then $pVer = $oPropValue EndIf If $pName <> "" And $pVer <> 0 Then Local $pVals[2] = [$pName, $pVer] Return $pVals EndIf EndIf WEnd EndFunc ;==>CheckInfo Link to comment Share on other sites More sharing options...
Earthshine Posted March 20, 2019 Share Posted March 20, 2019 (edited) Y I gave you the 64-bit key and you have to look under the 32-bit key I will post that as soon as I get back to the office because all MSI’s create that information. I can see the product code in your output and that goes in the registry you’re making this way too hard and you could install silently as well Edited March 20, 2019 by Earthshine My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
AasimPathan Posted March 20, 2019 Author Share Posted March 20, 2019 (edited) 2 minutes ago, rm4453 said: It was supposed to loop like that so it would be able to run infinitely and auto-update whenever the versions are different, however, I made so it will exit if it runs the deploy updated version. Also, the line 6-8 is supposed to be the file path to the local version of the MSI expandcollapse popup#include <AutoItConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> If FileExists("A:\U_A\U_W\U_Dpts\U_IT\U_Soft\C\U_Core\U_BayVL00\U_ReleaseMSIPackages\U_A_Core\U_Current\U_Source\bin\Release\MatrixCodeBase.msi") Then $sMSI = "A:\U_A\U_W\U_Dpts\U_IT\U_Soft\C\U_Core\U_BayVL00\U_ReleaseMSIPackages\U_A_Core\U_Current\U_Source\bin\Release\MatrixCodeBase.msi" ; set the local version infos for the MSI EndIf While 1 Sleep(25) $lVars = CheckInfo($sMSI) ; get the version infos for the local MSI $rVars = CheckInfo("A:\U_A\U_W\U_Dpts\U_IT\U_Soft\C\U_Core\U_BayVL00\U_ReleaseMSIPackages\U_A_Core\U_Current\U_Source\bin\Release\MatrixCodeBase.msi") ; get the version infos for the remote MSI If $lVars[0] = $rVars[0] And $lVars[1] <> $rVars[1] Then DeployNewVer() Exit EndIf WEnd Func DeployNewVer() Local $DisplayMsgBox = MsgBox($MB_YESNO, "Release components", "****Some Text***** Do you want to deploy? Press 'Yes' to Continue, Or press 'No' to Exit") Select Case $DisplayMsgBox = 6 ;Yes CloseRunningOfficePrograms() Sleep(1000) ;UninstallMatrixCodeBase() Sleep(1000) ;InstallMatrixCodeBase() Case $DisplayMsgBox = 7 ;No Exit EndSelect EndFunc ;==>DeployNewVer Func CloseRunningOfficePrograms() If ProcessExists("WINWORD.EXE") Then ProcessClose("WINWORD.EXE") If ProcessExists("EXCEL.EXE") Then ProcessClose("EXCEL.EXE") If ProcessExists("OUTLOOK.EXE") Then ProcessClose("OUTLOOK.EXE") If ProcessExists("VISIO.EXE") Then ProcessClose("VISIO.EXE") If ProcessExists("POWERPNT.EXE") Then ProcessClose("POWERPNT.EXE") EndFunc Func CheckInfo($sMSI) $oInstaller = ObjCreate("WindowsInstaller.Installer") $oDB = $oInstaller.OpenDataBase($sMSI, 0) $oView = $oDB.OpenView("SELECT Property,Value FROM Property") $oView.Execute() $oCount = 0 $pName = "" $pVer = 0 While @error = 0 $oRecords = $oView.Fetch $oPropValue = $oRecords.StringData(2) $oPropName = $oRecords.StringData(1) If $oPropName <> "" Then $oCount += 1 ConsoleWrite($oPropName & " = " & $oPropValue & @CRLF) If $oPropName = "ProductName" Then $pName = $oPropValue EndIf If $oPropName = "ProductVersion" Then $pVer = $oPropValue EndIf If $pName <> "" And $pVer <> 0 Then Local $pVals[2] = [$pName, $pVer] Return $pVals EndIf EndIf WEnd EndFunc ;==>CheckInfo Ps. There is no local MSI file btw There is a local installation of the msi package, so the program is installed but there is no .msi file anywhere on local computers. Would your script only work if we create a local copy of existing .msi file to the local computer? If not then i guess we would have to get version from the installed software right? Also I don't want it to run continuously, i will program Task Scheduler to run every few hours or days. so i don't need it running all the time Edited March 20, 2019 by AasimPathan Link to comment Share on other sites More sharing options...
Earthshine Posted March 20, 2019 Share Posted March 20, 2019 You’re making this too hard on yourself go look under the 32-bit uninstall key My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
rm4453 Posted March 20, 2019 Share Posted March 20, 2019 1 minute ago, AasimPathan said: Ps. There is no local MSI file btw There is a local installation of the msi package, so the program is installed but there is no .msi file anywhere on local computers. Would your script only work if we create a local copy of existing .msi file to the local computer? If not then i guess we would have to get version from the installed software right? or just make your update script drop a copy of the updated .MSI somewhere inside the install folder... Link to comment Share on other sites More sharing options...
AasimPathan Posted March 20, 2019 Author Share Posted March 20, 2019 Can someone help me finalize this, currently i am getting an error: "C:\Users\username\Desktop\U_A_A_OneClickDeployment_MatrixCodeBase.au3" (59) : ==> Subscript used on non-accessible variable.: If $GetMSIVersion[0] = $GetInstalledVersion[0] And $GetMSIVersion[1] <> $GetInstalledVersion[1] Then If $GetMSIVersion[0] = $GetInstalledVersion^ ERROR Basically what I did was first I am using AutoIT to extract the version of the installed software to a txt file. Then I am getting the version of MSI file. Then comparing the 2 version. So for eg. If installed Version is 1.0.0.0 or 0.0.9.0 etc. & MSI version is 1.0.1.0 we install the new package. But If installed version is 1.0.1.0 & MSI version is 1.0.1.0 we install do not install the package. expandcollapse popup#include <AutoItConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <Array.au3> #include <Misc.au3> #include <File.au3> #include <StringConstants.au3> $user = "DomainUser" $pass = "Password" $domain = "Domain" GetLocalInstalledVersion() Func GetLocalInstalledVersion() $sTextFile = ("A:\U_A\U_W\C_NonFiledFiles\GetVersion.txt") Run ( "notepad.exe " & $sTextFile, @WindowsDir, @SW_MAXIMIZE ) Local $hWnd = WinWait("[CLASS:Notepad]", "", 10) Local $aSoftwareList = _SoftwareList("Matrix Code Base") ;Search for specific software. GetMSIPackageVersion() EndFunc Func _SoftwareList($sSoftwareName = '') ;Search for MSI/Microsoft installed software using WindowsInstaller.Installer COM object. Local $oMyError = ObjEvent("AutoIt.Error", "_ComError") ;COM Error Handler #forceref $oMyError Local $aSoftwareList[1][3] Local $oInstaller = ObjCreate('WindowsInstaller.Installer') If Not IsObj($oInstaller) Then Return SetError(1, 0, $aSoftwareList) Local $Products = $oInstaller.Products For $Product In $Products If $sSoftwareName <> '' And Not StringInStr($oInstaller.ProductInfo($Product, 'ProductName'), $sSoftwareName) Then ContinueLoop ReDim $aSoftwareList[UBound($aSoftwareList) + 1][3] $aSoftwareList[UBound($aSoftwareList) - 1][0] = $oInstaller.ProductInfo($Product, 'ProductName') $aSoftwareList[UBound($aSoftwareList) - 1][1] = $oInstaller.ProductInfo($Product, 'VersionString') $aSoftwareList[UBound($aSoftwareList) - 1][2] = $oInstaller.ProductInfo($Product, 'InstallLocation') ClipPut($oInstaller.ProductInfo($Product, 'VersionString')) WinActivate ("[CLASS:Notepad]", "") Send("^a") Send("^v") Send("^s") Sleep(100) WinClose("[CLASS:Notepad]", "") Next $aSoftwareList[0][0] = UBound($aSoftwareList) - 1 Return $aSoftwareList EndFunc Func GetMSIPackageVersion() If FileExists("*\MatrixCodeBase.msi") Then $sMSI = "*\MatrixCodeBase.msi" EndIf While 1 Sleep(25) Local $GetMSIVersion = CheckMSIVersion($sMSI) ; get the version info of the msi installer Local $GetInstalledVersion = FileReadLine(FileOpen("*\GetVersion.txt"), 1) ; get the version info of the installed software. If $GetMSIVersion[0] = $GetInstalledVersion[0] And $GetMSIVersion[1] <> $GetInstalledVersion[1] Then CloseRunningOfficePrograms() EndIf WEnd EndFunc Func CloseRunningOfficePrograms() ;Closes all Running Microsoft Office Programs If ProcessExists("WINWORD.EXE") Then ProcessClose("WINWORD.EXE") If ProcessExists("EXCEL.EXE") Then ProcessClose("EXCEL.EXE") If ProcessExists("OUTLOOK.EXE") Then ProcessClose("OUTLOOK.EXE") If ProcessExists("VISIO.EXE") Then ProcessClose("VISIO.EXE") If ProcessExists("POWERPNT.EXE") Then ProcessClose("POWERPNT.EXE") InstallMatrixCodeBase() EndFunc Func InstallMatrixCodeBase() ;Install Matrix Code Base FileCopy("*\MatrixCodeBase.msi", "C:\Install") ;RunAsWait($user, $domain, $pass, 0, "msiexec /i C:\Install\MatrixCodeBase.msi /passive") ;Commented out because testing the process FileDelete("C:\Install\MatrixCodeBase.msi") EndFunc ;Miscellenous Functions required to run the primary scripts Func CheckMSIVersion($sMSI) $oInstaller = ObjCreate("WindowsInstaller.Installer") $oDB = $oInstaller.OpenDataBase($sMSI, 0) $oView = $oDB.OpenView("SELECT Property,Value FROM Property") $oView.Execute() $oCount = 0 $pName = "" $pVer = 0 While @error = 0 $oRecords = $oView.Fetch $oPropValue = $oRecords.StringData(2) $oPropName = $oRecords.StringData(1) If $oPropName <> "" Then $oCount += 1 ConsoleWrite($oPropName & " = " & $oPropValue & @CRLF) If $oPropName = "ProductName" Then $pName = $oPropValue EndIf If $oPropName = "ProductVersion" Then $pVer = $oPropValue EndIf If $pName <> "" And $pVer <> 0 Then Local $pVals[2] = [$pName, $pVer] Return $pVals EndIf EndIf WEnd EndFunc Func _ComError($oMyError) ;COM Error function defined in COM Error Handler used in COM functions. MsgBox(16, "AutoItCOM ERROR!", "COM Error Intercepted!" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & Hex($oMyError.number, 8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) EndFunc Link to comment Share on other sites More sharing options...
Earthshine Posted March 20, 2019 Share Posted March 20, 2019 here are both keys to check, you are way over complicating this 2 3 HKEY_LOCAL_MACHINE:\Software\Microsoft\Windows\CurrentVersion\Uninstall HKEY_LOCAL_MACHINE:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall the second one is the 32 bit, where yours lives also, use silent install I'm out. My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
AasimPathan Posted March 21, 2019 Author Share Posted March 21, 2019 16 hours ago, Earthshine said: here are both keys to check, you are way over complicating this 2 3 HKEY_LOCAL_MACHINE:\Software\Microsoft\Windows\CurrentVersion\Uninstall HKEY_LOCAL_MACHINE:\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall the second one is the 32 bit, where yours lives also, use silent install I'm out. Can you write that in code please? as i don't know how to do that part well. I am more of a IT admin rather than a scripter/coder. Link to comment Share on other sites More sharing options...
Earthshine Posted March 21, 2019 Share Posted March 21, 2019 I’ll Post code later when in office My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
Earthshine Posted March 21, 2019 Share Posted March 21, 2019 I need your guid or an installer that i can install to a vm and find it. My resources are limited. You must ask the right questions Link to comment Share on other sites More sharing options...
AasimPathan Posted March 22, 2019 Author Share Posted March 22, 2019 17 hours ago, Earthshine said: I need your guid or an installer that i can install to a vm and find it. Hi, Well I got it work but i'll paste the script here just in case you want to see if i might get any issues. expandcollapse popup#include <AutoItConstants.au3> #include <FileConstants.au3> #include <MsgBoxConstants.au3> #include <WinAPIFiles.au3> #include <Array.au3> #include <Misc.au3> #include <File.au3> #include <StringConstants.au3> ;Minimum required version of the Matrix Code Base is 1.0.3.0 ;This script will not function if the version is lower than the above Global $Username = "ServerAdmin" Global $Password = "PasswordInPlain" ;I am trying to see if we can encypt this and any passwords we use in AutoIt but for now its set as plain text Global $Domain = "Domain" ;The above login is required to execute the installer, if the credentials are not provided then the installer will prompt each user to enter a username & password and therefore fail to install since standard users do not have any rights to install a software Global $MSIPath = "A:\SomePath\SomeFolder\SomeSubFolder\MatrixCodeBase.msi" ; MSI Package path Global $GetMSIVersion = QueryMSIPackage($MSIPath,'ProductVersion') ; get the version info of the msi installer Global $GetInstalledVersion = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{8B3DFDFF-D894-4A31-AA92-824729385F15}", "DisplayVersion") ; get the version info of the installed software. While 1 Sleep(25) If $GetInstalledVersion = @error Then InstallMatrixCodeBase() ElseIf $GetMSIVersion = $GetInstalledVersion Then Exit ElseIf $GetMSIVersion <> $GetInstalledVersion Then InstallMatrixCodeBase() EndIf ExitLoop WEnd Func CloseRunningOfficePrograms() ;Closes all Running Microsoft Office Programs If ProcessExists("EXCEL.EXE") Then ProcessClose("EXCEL.EXE") If ProcessExists("OUTLOOK.EXE") Then ProcessClose("OUTLOOK.EXE") If ProcessExists("POWERPNT.EXE") Then ProcessClose("POWERPNT.EXE") If ProcessExists("VISIO.EXE") Then ProcessClose("VISIO.EXE") If ProcessExists("WINWORD.EXE") Then ProcessClose("WINWORD.EXE" InstallMatrixCodeBase() EndFunc Func InstallMatrixCodeBase() ;Install Matrix Code Base FileCopy("A:\SomePath\SomeFolder\SomeSubFolder\MatrixCodeBase.msi", "C:\Install") RunAsWait($user, $domain, $pass, 0, "msiexec /i C:\Install\MatrixCodeBase.msi /passive") EndFunc Func QueryMSIPackage($sMSI, $PropertyName) ; Query the MSI installer to get installer properties If FileExists($MSIPath) And $PropertyName <> '' Then Local $Query = "SELECT Value FROM Property WHERE Property = '" & $PropertyName & "'" $oInstaller = ObjCreate("WindowsInstaller.Installer") $oDB = $oInstaller.OpenDataBase($sMSI, 0) $oView = $oDB.OpenView($Query) $oView.Execute() $oRecords = $oView.Fetch $oPropValue = $oRecords.StringData(1) If $oPropValue <> "" Then Return $oPropValue EndIf EndIf Return "" EndFunc Func _ComError($oMyError) ;COM Error function defined in COM Error Handler used in COM functions. MsgBox(16, "AutoItCOM ERROR!", "COM Error Intercepted!" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & Hex($oMyError.number, 8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) EndFunc Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now