1
votes

In order to automate some actions in MSI I have been trying to insert into RemoveFile table using JScript and keep getting errors and since there is not much error description i am not able to figure out the issue in query and the only error that i get when i try to debug using csript is -2147467259 OpenView,SQL,

This is the query that i am using to insert into removefile table, Can anyone please help me figuring out the issue.

"INSERT INTO `RemoveFile` (`FileKey`, `Component_`, `FileName`, `DirProperty`, `InstallMode`) VALUES (`_142D31F52C744D6FB945F01BA06EEFB3`, `C__931358B017AE83C769F5CB9E95BD2401`, `Product version 2.0.lnk`, `DesktopFolder`, 1)
1
When are you trying to do this - at runtime in a custom action or just on an existing MSI file? There is a " missing from the end of your statement, if that helps... Have you tried executing the statement using the wirunsql.vbs tools you get with the SDK? - Stephen Connolly
Hi Stephen, thanks for your reply. sorry about the missing " at the end which was a typo but that was not the issue. the real problem was in the VALUES section i have to use '' and not `` which was breaking the query. - Jignesh

1 Answers

0
votes

Have you opened the view on the installer database?

var installer = WScript.CreateObject("WindowsInstaller.Installer");
var database = installer.OpenDatabase(<your-product.msi>,
                                      msiOpenDatabaseModeTransact);

sql = "INSERT INTO `RemoveFile` "
          + "(`FileKey`, `Component_`, `FileName`, "
              + "`DirProperty`, `InstallMode`) "
          + "VALUES ('_142D31F52C744D6FB945F01BA06EEFB3', "
                   + "'C__931358B017AE83C769F5CB9E95BD2401', "
                   + "'Product version 2.0.lnk', 'DesktopFolder', 1)";
view = database.OpenView(sql);
view.Execute();
view.Close();