Vijaya7890

How to create a new record in Binary Table in MSI

2 posts in this topic

Hi...

I am trying to add a record in Binary Table in an MSI file.

As Binary table has two fields/columns Name &Data , I am giving any string for Name(column 1) and streaming binary data from a VBS file into Data(column 2) .

I have tried with VB script and it is working fine,

Here is the VB Script file

Dim Installer
Dim Database
Dim View
Dim Record
Dim query
query="INSERT INTO `Binary` (`Name`, `Data`) VALUES ('NewBlob', ?)"
Set Installer = CreateObject("WindowsInstaller.Installer")

Set Record = Installer.CreateRecord(1)
Record.SetStream 1, "C:\Users\Admin\Desktop\coder\CA_Test.vbs"

Set Database = Installer.OpenDatabase("C:\Users\Admin\Desktop\7z920.msi", 1)

Set View = Database.OpenView(query)
View.Execute Record
Database.Commit

when i tried the same thing in autoit it is not working and it is not giving any syntax error.

AutoIt file: 

#include <File.au3>

$idVarInput_CAName="CA_Test"
$filepath="C:\Users\Admin\Desktop\coder\CA_Test.vbs"
$idVarInput_MSIPath="C:\Users\Admin\Desktop\7z920.msi"
$value="?"

Local $Query = "INSERT INTO Binary(Name,Data) VALUES('" & $idVarInput_CAName & "','" & $value & "')"

$oInstaller = ObjCreate("WindowsInstaller.Installer")
$oRec=$oInstaller.CreateRecord(1)
$r=$oRec.SetStream(1,$filepath)
$oDB = $oInstaller.OpenDataBase($idVarInput_MSIPath,1)
$oView = $oDB.OpenView($Query)
$oView.Execute($oRec)
$oDB.commit()

Please Help!

Thanks...

Share this post


Link to post
Share on other sites



3 hours ago, Vijaya7890 said:

Hi...

I am trying to add a record in Binary Table in an MSI file.

As Binary table has two fields/columns Name &Data , I am giving any string for Name(column 1) and streaming binary data from a VBS file into Data(column 2) .

I have tried with VB script and it is working fine,

Here is the VB Script file

Dim Installer
Dim Database
Dim View
Dim Record
Dim query
query="INSERT INTO `Binary` (`Name`, `Data`) VALUES ('NewBlob', ?)"
Set Installer = CreateObject("WindowsInstaller.Installer")

Set Record = Installer.CreateRecord(1)
Record.SetStream 1, "C:\Users\Admin\Desktop\coder\CA_Test.vbs"

Set Database = Installer.OpenDatabase("C:\Users\Admin\Desktop\7z920.msi", 1)

Set View = Database.OpenView(query)
View.Execute Record
Database.Commit

when i tried the same thing in autoit it is not working and it is not giving any syntax error.

AutoIt file: 

#include <File.au3>

$idVarInput_CAName="CA_Test"
$filepath="C:\Users\Admin\Desktop\coder\CA_Test.vbs"
$idVarInput_MSIPath="C:\Users\Admin\Desktop\7z920.msi"
$value="?"

Local $Query = "INSERT INTO Binary(Name,Data) VALUES('" & $idVarInput_CAName & "','" & $value & "')"

$oInstaller = ObjCreate("WindowsInstaller.Installer")
$oRec=$oInstaller.CreateRecord(1)
$r=$oRec.SetStream(1,$filepath)
$oDB = $oInstaller.OpenDataBase($idVarInput_MSIPath,1)
$oView = $oDB.OpenView($Query)
$oView.Execute($oRec)
$oDB.commit()

Please Help!

Thanks...

Change the query line as below

Local $Query = "INSERT INTO `Binary`(`Name`,`Data`) VALUES('" & $idVarInput_CAName & "'," & $value & ")"

In your code... is surrounded by single quotes as '?'.So your query isn't able to be parsed.

I removed only the single quote part...it is working..

1 person likes this

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • Rammanan
      By Rammanan
      Hi all,
      I new for Autoit.  Below is my code. It all work fine but after set text at drop down box function controlclick not work(No click on button). Please help me to solve this problem. Thanks
      if(WinWaitActive("Clotho -- Next Generation Avago WSD ATE Framework", "", 40)) then
         ControlSetText("Clotho -- Next Generation Avago WSD ATE Framework", "", "[NAME:textboxUserName]", $User)
         ControlClick("Clotho -- Next Generation Avago WSD ATE Framework", "", "[NAME:buttonLogin]")
         Do
         until WinWait ("Clotho -- Next Generation Avago WSD ATE Framework")
         WinActivate("Clotho -- Next Generation Avago WSD ATE Framework")
        ControlClick("Clotho -- Next Generation Avago WSD ATE Framework", "", "[Name:comboBoxPackage]")
        While 1
          Send("{DOWN}")
          $ctext=ControlGetText("Clotho -- Next Generation Avago WSD ATE Framework","","[Name:comboBoxPackage]")
          If $ctext= $Product Then
             ControlClick("Clotho -- Next Generation Avago WSD ATE Framework", "", "[Name:comboBoxPackage]")
             WinActivate("Clotho -- Next Generation Avago WSD ATE Framework")
             ControlClick("Clotho -- Next Generation Avago WSD ATE Framework", "", "[Name:buttonExecutionStart]")
             ExitLoop
          EndIf
       WEnd
       EndIf
    • vikashbitm2010
      By vikashbitm2010
      Hi all,
      I want to return string from autoit script to the python code.
      Autoit:
      Exit("22 FE 45") -> not working
      Exit(1) -> Working
      Exit(0) -> Working
      python:
      import os
      res=os.system(autoitmine.exe)
      print "res",res
      I got some hint of @ExitCode macro, but dont know how to use it to get the string in python variable 'res'.
      Please resolve this issue for me if anyone knows about this.
       
    • QuickWhiteWolf
      By QuickWhiteWolf
      Hi everyone,
       
      I was previously a member of this forum under the username Wombat. It's been years and multiple email accounts closed since then so I decided to start fresh and take a moment to thank you all... (Admins/Mods let me know if we need to discuss this...)
       
      I started programming with AutoIT while working as a scrap catcher for a machine that chopped scrap into pieces for easier moving, I learned styles and gained strengths from some of the best members on this forum by reverse engineering their code. I gained the confidence of our IT manager by making a boast that I could write an application to replace a p.o.s. cobalt based app we were using on the floor at that time, needless to say I was way in over my head but he saw that I had potential and I luckily had built several other apps on the side that were of equal or greater value to the company. I've been working as help-desk for the past 3 years and writing software as well to facilitate the help desk and solve recurring issues with our users. I was given an office and moved out of help-desk about a year ago, after 5 years of hard work I've actually landed the title of Jr. Developer moving into mid level title/pay this year! The company has already set out an improvement path that sees me with 4 certs and a bachelors in 4 more years making great money. Before this I had only ever worked at gas stations, fast food and manual labor jobs. If you're ever worried about your life, want something more, or just want a change you can do it. It's not easy, not at all, but it's possible and software programming is a very rewarding field if you like to make things and see how others interact with them.

      I utilized AutoIT to bring a company into the twenty-first century, away from paper trails and sticky notes improving the quality of life for the employees on the floor (where I started before learning AutoIT). I was given the go ahead to purchase visual studio and I learned VB.Net and built an awesome piece of Zebra labeling software (Utilizing ZPL code translated froma graphical editor) for our shipping department. Now I'm diving head first into C# and we have another programmer on board as we move on to MS Team Services and begin to tackle a sweet new project involving real time awareness of our product on the factory floor utilizing RFID and windows 10 tablets.

      That's a long way to come in just 4 years, and I couldn't have done it without the gigantic heart this community has and the mentorship provided for people looking to get into programming.

      So from the bottom of my heart, with immense respect.... Thank you so much AutoIT community
    • Valnurat
      By Valnurat
      Hi.
      How do you find all printers installed on a computer?
      I'm searching for the name, location and port
       
    • anub13
      By anub13
      Hi,

      I am having difficulties wondering why my code bugging like this,
      the symptom : I have a form with combo box, and details in bottom of the app, when user choose another option the details changes immediately but when I go to details, it goes up and down endlessly
      here is the code
       
      Global $cChkPatrol, $YES= "YES", $NO = "NO" if GUICtrlRead($combo1) = "YES" Then $cChkPatrol = $YES Else $cChkPatrol = $NO EndIf func StartForm() GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & asdfgSystemInfo()) GUISetState(@SW_SHOW) AdlibRegister("_CheckPatrol") While 1 $nMsg = GUIGetMsg() Select case $nMsg = $txtEmailAddress GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & asdfgSystemInfo()) case $nMsg = $txtPhone GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & asdfgSystemInfo()) case $nMsg = $txtFullName GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & asdfgSystemInfo()) case $nMsg = $cChkPatrol GUICtrlSetData($txtInfo,"ADDITIONAL INFORMATION THAT WILL BE SENT WITH THE MESSAGE:" & @CRLF & asdfgSystemInfo()) case $nMsg = $cmdScreenShot $gScreenShotFile = SaveScreenShot() case $nMsg = $cmdSubmit if ValidateForm() then if asdfgSubmit() Then UpdateStatus("Your request has been sent successfully") MsgBox(0,"Help Requested","Your request has been sent successfully") ExitLoop Else MsgBox(0,"Help Failed","Something is wrong you request was not sent, please try again") Endif endIf case $nMsg = $cmdAttach $gAttachFile = AttachFile() Case $nMsg = $GUI_EVENT_CLOSE ExitLoop EndSelect WEnd AdlibUnRegister("_CheckPatrol") EndFunc func asdfgSystemInfo() dim $asdfgInfo $asdfgInfo = "" & @CRLF if $isAdminVersion=1 then $asdfgInfo = $asdfgInfo & @CRLF & " Ticket Tags:" & @CRLF $asdfgInfo = $asdfgInfo & "~#userphone='" & GUICtrlRead($txtPhone) & "'" & @CRLF $asdfgInfo = $asdfgInfo & "~#submitterphone='" & GUICtrlRead($txtPhone) & "'" & @CRLF dim $MachineID $MachineID = KaseyaIni($gKIniFile,"SERVER COMMUNICATIONS","User_Name","NotFound") $asdfgInfo = $asdfgInfo & "~#machineid='" & $MachineID & "'" & @CRLF dim $OrgGroups $OrgGroups= StringSplit($MachineID,".") dim $OrgGroupIndex $OrgGroupIndex = UBound($OrgGroups) - 1 $asdfgInfo = $asdfgInfo & "~#organization='" & $OrgGroups[$OrgGroupIndex] & "'" & @CRLF dim $EmailUser $EmailUser = GUICtrlRead($txtEmailAddress) $EmailUser = StringMid($EmailUser,1,StringInStr($EmailUser,"@") - 1) & @CRLF & @CRLF $asdfgInfo = $asdfgInfo & "~#username='" & $EmailUser & "'" & @CRLF ;dim ;Call("isChecked") ;$categ = GUICtrlRead($chkPatrol) ;$asdfgInfo = $asdfgInfo & "-#category='" & $categ & "'" & @CRLF EndIf $asdfgInfo = $asdfgInfo & "Email:" & GUICtrlRead($txtEmailAddress) & @CRLF & @CRLF $asdfgInfo = $asdfgInfo & "Full Name:" & GUICtrlRead($txtFullName) & @CRLF & @CRLF $asdfgInfo = $asdfgInfo & "Phone:" & GUICtrlRead($txtPhone) & @CRLF & @CRLF $asdfgInfo = $asdfgInfo & "DateTime:" & _Now() & @CRLF $asdfgInfo = $asdfgInfo & "MachineName:" & @ComputerName & @CRLF $asdfgInfo = $asdfgInfo & "UserName:" & @UserName & @CRLF $asdfgInfo = $asdfgInfo & "OS:" & @OSType & " " & @OSVersion & @CRLF $asdfgInfo = $asdfgInfo & "LogonDomain:" & @OSType & " " & @LogonDomain & @CRLF $asdfgInfo = $asdfgInfo & "LogonDNSDomain:" & @OSType & " " & @LogonDNSDomain & @CRLF $asdfgInfo = $asdfgInfo & "OS:" & @OSType & " " & @OSVersion & @CRLF $asdfgInfo = $asdfgInfo & "IP Address:" & @IPAddress1 & @CRLF $asdfgInfo = $asdfgInfo & "Public IP Address:" & GetPublicIP() &@CRLF ;$asdfgInfo = $asdfgInfo & "Public IP Address:" & _GetIP () &@CRLF $asdfgInfo = $asdfgInfo & "OS:" & NetAdapterInfo() $asdfgInfo = $asdfgInfo & "KaseyaInstalled:" & KaseyaInstalled() & @CRLF $asdfgInfo = $asdfgInfo & "KaseyaRunning:" & KaseyaRunning() & @CRLF $asdfgInfo = $asdfgInfo & "KaseyaAgentGUID:" & KaseyaIni($gKIniFile,"SERVER COMMUNICATIONS","Agent_Guid","NotFound") & @CRLF $asdfgInfo = $asdfgInfo & "asdfgPaid:" & isasdfgIDPaid() & @CRLF if $isAdminVersion=0 then $asdfgInfo = $asdfgInfo & @CRLF & " Ticket Tags:" & @CRLF $asdfgInfo = $asdfgInfo & "~userphone='" & GUICtrlRead($txtPhone) & "'" & @CRLF $asdfgInfo = $asdfgInfo & "~submitterphone='" & GUICtrlRead($txtPhone) & "'" & @CRLF dim $MachineID $MachineID = KaseyaIni($gKIniFile,"SERVER COMMUNICATIONS","User_Name","NotFound") $asdfgInfo = $asdfgInfo & "~machineid='" & $MachineID & "'" & @CRLF dim $OrgGroups $OrgGroups= StringSplit($MachineID,".") dim $OrgGroupIndex $OrgGroupIndex = UBound($OrgGroups) - 1 $asdfgInfo = $asdfgInfo & "~organization='" & $OrgGroups[$OrgGroupIndex] & "'" & @CRLF dim $EmailUser $EmailUser = GUICtrlRead($txtEmailAddress) $EmailUser = StringMid($EmailUser,1,StringInStr($EmailUser,"@") - 1) $asdfgInfo = $asdfgInfo & "~username='" & $EmailUser & "'" & @CRLF dim $categ $categ = $chkPatrol $asdfgInfo = $asdfgInfo & "~category='" & $categ & "'" & @CRLF dim $track $track = $cChkPatrol $asdfgInfo = $asdfgInfo & "~test='" & $cChkPatrol & "'" & @CRLF $asdfgInfo = $asdfgInfo & "~afterhour='" & $AfterHour & "'" & @CRLF endif Return $asdfgInfo endFunc  
      Yes it was same app as previous post in the forum I asked, I also having experience this happening before but I fail to understand the reason why this is happening. Thanks in advance.
      ButtonSupport - Copy.au3