Jump to content

Recommended Posts

Posted

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...

Posted
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..

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
×
×
  • Create New...