ur Posted October 25, 2019 Posted October 25, 2019 (edited) In windows installer/msi, we can add custom actions using vbscript directly. Now, they provide support for powershell also. Where, we can access data in the installer using this code like properties,product code, installation folder,etc. But there is no option to use by AutoIT directly.(As far as I know) So, till now, I am compiling the autoit exe and calling it in msi using below option of launching an exe. But, this way, I can't access msi properties inside it. Any idea on how to access msi data inside it, so that I can disable some msi UI buttons using the autoit code. Edited October 25, 2019 by ur
Developers Jos Posted October 25, 2019 Developers Posted October 25, 2019 Please simply post the code here in a codebox instead of external images. I for one am reluctant to click on external links to have to look at an image. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
ur Posted October 25, 2019 Author Posted October 25, 2019 Hi @Jos Sure, but above snaps not of code, I am showing the options in Installshield tool. And, is there any possibility to increase my attachment limit as it is exceeded.
Developers Jos Posted October 25, 2019 Developers Posted October 25, 2019 Well you can share all required info here either way. So show the working vbs and the result so we can understand what you are looking for. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
ur Posted October 25, 2019 Author Posted October 25, 2019 If using vbscript we can use properties as in msi embedded code using. var1 = Session.Property("PROPERTY1") Session.Property("PROPERTY2")="somedata" Is there any alternate in autoit for msi like that?
ur Posted October 25, 2019 Author Posted October 25, 2019 In the below AutoIT code, I have compiled it as exe and using in the msi customaction type "launch exe from binary table" The below code will check whether the credentials provided in the installer screens by user are correct or not. I am passing the data using command line arguments as I don't find option to access msi database from autoit. expandcollapse popup#include <MsgBoxConstants.au3> #include <StringConstants.au3> if ($CmdLine[0]<2) Then Msg("Please enter both username and password") Exit(1) EndIf if ((StringLen(StringStripWS($CmdLine[1], $STR_STRIPLEADING + $STR_STRIPTRAILING))=0) or (StringLen(StringStripWS($CmdLine[2], $STR_STRIPLEADING + $STR_STRIPTRAILING))=0)) Then Msg("Please enter both username and password") Exit(1) EndIf $user = StringStripWS($CmdLine[1], $STR_STRIPLEADING + $STR_STRIPTRAILING) $password = StringStripWS($CmdLine[2], $STR_STRIPLEADING + $STR_STRIPTRAILING) if ((StringLen($user)=0) or (StringLen($password)=0)) Then Msg("Please enter both username and password") Exit(1) EndIf $domain = @ComputerName if(StringInStr($user,"\",2) > 0) then if not (StringCompare ( StringSplit($user,"\")[1], ".")=0) then $domain = StringSplit($user,"\")[1] EndIf $user = StringSplit($user,"\")[2] EndIf ;MsgBox(0,$domain&"\"&$user,$password) if _ValidUserPass($user,$domain,$password) Then Msg("Credentials are working",False) Else Msg("Credentials are Invalid!") EndIf Func _ValidUserPass($username, $computer, $password) Local $valid = True RunAs($username, $computer, $password, 0, @ComSpec & " /c echo test", @SystemDir, @SW_Hide) If @error Then $valid = False Return $valid EndFunc Func Msg($sMsg,$error=True) if ($error=True) then MsgBox($MB_ICONERROR,"Authentication Failed!",$sMsg) Else MsgBox($MB_ICONINFORMATION,"Authentication Successful!",$sMsg) EndIf EndFunc But now, the user is asking to disable next button if it fails instead of error messages. So far, so how to achieve this, i.e., to control msi tables data from autoit
abberration Posted October 25, 2019 Posted October 25, 2019 I'm not sure if this will help you or not, but this is a neat resource reader/extractor: Easy MP3 | Software Installer | Password Manager
ur Posted October 25, 2019 Author Posted October 25, 2019 No, I think you mistook me. In simple words, windows installer (.msi files) are used to install our resources on windows machine. As installer format provided by Microsoft. Internally, it is just a set of tables. Like, file table will have details where to install and what to install. Registry table contains what are the registries to apply. If we need more logic, we can embed any vbscript or powershell files inside it. As, we can write this vbscript code directly, we can access these msi tables from our vbscript code.Like below. var1 = Session.Property("ProductCode") Like this, is there any option in autoit to access the proerties/any msi table data from autoit code.?
Zedna Posted October 25, 2019 Posted October 25, 2019 (edited) Add third commandline parameter = MSI process full path+name and in AutoIt use this to find GUI window and use ControlDisable() on that GUI for disabling of particular Next button. Edited October 25, 2019 by Zedna Resources UDF ResourcesEx UDF AutoIt Forum Search
Nine Posted October 25, 2019 Posted October 25, 2019 (edited) 1 hour ago, ur said: As, we can write this vbscript code directly, we can access these msi tables from our vbscript code.Like below. var1 = Session.Property("ProductCode") Like this, is there any option in autoit to access the proerties/any msi table data from autoit code.? Like this : $sMSI = "YourProduct.msi" $oInstaller = ObjCreate("WindowsInstaller.Installer") $oDB = $oInstaller.OpenDataBase($sMSI, 0) $oView = $oDB.OpenView("SELECT Property,Value FROM Property WHERE Property = 'ProductCode'") $oView.Execute() $oRecords = $oView.Fetch if not IsObj ($oRecords) then Exit MsgBox ($MB_SYSTEMMODAL,"","Error reading msi Table") $sValue = $oRecords.StringData(2) ConsoleWrite($sValue & @CRLF) Edited October 25, 2019 by Nine “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
ur Posted October 25, 2019 Author Posted October 25, 2019 3 hours ago, Nine said: Like this : $sMSI = "YourProduct.msi" $oInstaller = ObjCreate("WindowsInstaller.Installer") $oDB = $oInstaller.OpenDataBase($sMSI, 0) $oView = $oDB.OpenView("SELECT Property,Value FROM Property WHERE Property = 'ProductCode'") $oView.Execute() $oRecords = $oView.Fetch if not IsObj ($oRecords) then Exit MsgBox ($MB_SYSTEMMODAL,"","Error reading msi Table") $sValue = $oRecords.StringData(2) ConsoleWrite($sValue & @CRLF) This is for opening an external msi. But is there any code for running inside msi itself through custom action?
Nine Posted October 25, 2019 Posted October 25, 2019 2 hours ago, ur said: But is there any code for running inside msi itself through custom action? It is like asking to have AutoIt being part of Excel scripting language inside itself. Can you understand, it is not possible ? But you can do pretty much do all you want outside of it. “They did not know it was impossible, so they did it” ― Mark Twain Spoiler Block all input without UAC Save/Retrieve Images to/from Text Monitor Management (VCP commands) Tool to search in text (au3) files Date Range Picker Virtual Desktop Manager Sudoku Game 2020 Overlapped Named Pipe IPC HotString 2.0 - Hot keys with string x64 Bitwise Operations Multi-keyboards HotKeySet Recursive Array Display Fast and simple WCD IPC Multiple Folders Selector Printer Manager GIF Animation (cached) Debug Messages Monitor UDF Screen Scraping Round Corner GUI UDF Multi-Threading Made Easy Interface Object based on Tag
Developers Jos Posted October 26, 2019 Developers Posted October 26, 2019 I am still missing the requested VBS code (not the oneliner) that gets you the information from the installer so we can understand what you do exactly. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
ur Posted October 27, 2019 Author Posted October 27, 2019 I don't have any vbscript code for that. Just I am telling vbscript as an example. vbscript and powershell has direct access to msi database if we embed them as custom action(embedded code) inside msi. But, autoit (when I embed the exe launching inside msi custom action), how to get access to the database?
Developers Jos Posted October 27, 2019 Developers Posted October 27, 2019 As i have no knowledge of what you are talking about, and you haven't provided any example of what you say is working in vbs & powershell, there isn't much I can do here as I am not going to spent time of researching this myself. Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Deye Posted October 27, 2019 Posted October 27, 2019 On 10/25/2019 at 1:18 PM, ur said: Is there any alternate in autoit for msi like that? I dont think you will find any built autoit snippets that deal with msi properties Try maybe ORCS MSI Editor or searching msfn Maybe you will find there some old posts that relate with what you are looking for
ur Posted October 30, 2019 Author Posted October 30, 2019 (edited) It seems, no support to interact with msi database through autoit directly. So, at present, I created a vbscript through which I am calling autoit and using the return values from autoit, I am setting the properties of msi (like disabling next button using) using vbscript. My vbscript code. Dim oFSO : Set oFSO = CreateObject("Scripting.FileSystemObject") Dim outputFile : outputFile = Session.Property("SUPPORTDIR") & "\autoitexe.exe" If oFSO.fileExists(outputFile) Then Dim objShell : Set objShell = CreateObject("WScript.Shell") user = Session.Property("SCHEDULERLOCALSYSTEM_USER") password = Session.Property("SCHEDULERLOCALSYSTEM_PASSWORD") iReturn = objShell.Run(""""&outputFile&""" "& user &" "& password,0,True) if (iReturn = 1) then 'MsgBox iReturn Session.Property("SCHEDULER_ENABLE_NEXT") = "0" 'MsgBox iReturn else Session.Property("SCHEDULER_ENABLE_NEXT") = "1" end if Set objShell = Nothing End If Set oFSO = Nothing and the code for my autoit exe. expandcollapse popup#include <MsgBoxConstants.au3> #include <StringConstants.au3> if ($CmdLine[0]<2) Then Msg("Please enter both username and password") Exit(1) EndIf if ((StringLen(StringStripWS($CmdLine[1], $STR_STRIPLEADING + $STR_STRIPTRAILING))=0) or (StringLen(StringStripWS($CmdLine[2], $STR_STRIPLEADING + $STR_STRIPTRAILING))=0)) Then Msg("Please enter both username and password") Exit(1) EndIf $user = StringStripWS($CmdLine[1], $STR_STRIPLEADING + $STR_STRIPTRAILING) $password = StringStripWS($CmdLine[2], $STR_STRIPLEADING + $STR_STRIPTRAILING) if ((StringLen($user)=0) or (StringLen($password)=0)) Then Msg("Please enter both username and password") Exit(1) EndIf $domain = @ComputerName if(StringInStr($user,"\",2) > 0) then if not (StringCompare ( StringSplit($user,"\")[1], ".")=0) then $domain = StringSplit($user,"\")[1] EndIf $user = StringSplit($user,"\")[2] EndIf ;MsgBox(0,$domain&"\"&$user,$password) if _ValidUserPass($user,$domain,$password) Then Msg("Credentials are working",False) Exit(0) Else Msg("Credentials are Invalid!") Exit(1) EndIf Func _ValidUserPass($username, $computer, $password) Local $valid = True RunAs($username, $computer, $password, 0, @ComSpec & " /c echo test", @SystemDir, @SW_Hide) If @error Then $valid = False Return $valid EndFunc Func Msg($sMsg,$error=True) if ($error=True) then MsgBox($MB_ICONERROR,"Authentication Failed!",$sMsg) Else ;MsgBox($MB_ICONINFORMATION,"Authentication Successful!",$sMsg) EndIf EndFunc Thank you very much guys, for your help Edited October 30, 2019 by ur
Earthshine Posted October 30, 2019 Posted October 30, 2019 (edited) why cant the installer use custom actions and do it there in code? or just do it in vbscript--as that looks like your package manager uses (ugh) Edited October 30, 2019 by Earthshine My resources are limited. You must ask the right questions
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