Sign in to follow this  
Followers 0
benners

[Problem]

1 post in this topic

I am trying to update an MSI's registry table with a key I would like to have the MSI import when run. I am using a blank template from the MsiIntel.SDK and testing with a random key from the registry.

I have used Orca to import the reg file and then tried to mimic the entry using AutoIt, the code I am using is below

#cs
    File test.msi is a blank msi template from MsiIntel.SDK (Called Schema.msi)
    
    Table to edit = Regsitry
    
    Table Headers & Data to Add = Registry    - NewRegKey1
    Table Headers & Data to Add = Root        - 2
    Table Headers & Data to Add = Key          - SOFTWARE\Microsoft\Windows\CurrentVersion\Run
    Table Headers & Data to Add = Name        - nwiz
    Table Headers & Data to Add = Value      - nwiz.exe /install
    Table Headers & Data to Add = Component_    - ISRegistryComponent
#ce

Dim $Installer, $Database, $SQL, $View
Dim $MSI = 'C:\Test\Test.msi'

$Installer = ObjCreate("WindowsInstaller.Installer")
$Database = $Installer.OpenDatabase($MSI, 1)
;$SQL = "INSERT INTO `Feature` (`Feature`.`Feature`,`Feature`.`Feature_Parent`,`Feature`.`Title`,`Feature`.`Description`, `Feature`.`Display`,`Feature`.`Level`,`Feature`.`Directory_`,`Feature`.`Attributes`) VALUES ('Tennis','Sport','Tennis','Tournament',25,3,'SPORTDIR',2)"
$SQL = "INSERT INTO `Registry` (`Registry`,`Root`,`Key`,`Name`,`Value`,`Component_`) VALUES (`NewRegKey1`,`2`,`SOFTWARE\Microsoft\Windows\CurrentVersion\Run`,`nwiz`,`nwiz.exe /install`,`ISRegistryComponent`)"
$View = $Database.OpenView($SQL)
$View.Execute
$Database.Commit; save changes

I have found some info on MSDN doing what I want to do and using the code on the page in my example it works. The commented SQL entry is the code from the MSDN page.

When I try my code for the registry table I get an error saying The requested action with this object has failed so I tried using the VBScript listed on the MSDN page (WiRunSQL.vbs) using my $SQL code and an error also occurred which was

Msi API Error 80004005: OpenView,Sql

1: 2227 2: C:\Test\Test.msi 3: NewRegKey1 4: INSERT INTO `Registry` (`Registry`.`Registry`,`Registry`.`Root`,`Registry`.`Key`,`Registry`.`Name`,`Registry`.`Value`,`Registry`.`Component_`) VALUES (NewRegKey1,`2`,`SOFTWARE\Microsoft\Windows\CurrentVersion\Run`,`nwiz`,`nwiz.exe /install`,`ISRegistryComponent`)

looking on the MSDN site lead me here to where the errors are referenced and it is saying that the NewRegKey1 is an invalid identifier but looking here I cannot see why it is invalid.

It's not really an AutoIt problem but it is frustrating as I think I am close to doing what I want after days of searching for answers, I would appreciate if someone could help me locate the problem.

cheers.

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
Sign in to follow this  
Followers 0