cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
ishielduser11
Level 3

Delete property from MSI file

Hi,


I have one "simple" 😄 question, why it doesn't work (install script):

nr_res = MsiOpenDatabase("C:\MyProg.msi", MSIDBOPEN_DIRECT, hDatabase);

if(nr_res == ERROR_SUCCESS) then
ok = TRUE;
endif;

nr_res = MsiDatabaseOpenView(hDatabase, "DELETE FROM Property WHERE Property = 'MyProperty'", hView);

if(nr_res == ERROR_SUCCESS) then
ok = TRUE;
endif;

nr_res = MsiViewExecute(hView, NULL);

if(nr_res == ERROR_SUCCESS) then
ok = TRUE;
endif;

nr_res = MsiViewExecute(hView, 0);

if(nr_res == ERROR_SUCCESS) then
ok = TRUE;
endif;

nr_res = MsiViewClose(hView);

if(nr_res == ERROR_SUCCESS) then
ok = TRUE;
endif;

nr_res = MsiDatabaseCommit(hDatabase);

if(nr_res == ERROR_SUCCESS) then
ok = TRUE;
endif;


After execute msi file still got property "MyProperty". It is possilbe to delete property (or Action from InstallExecuteSequence) from MSI file using Install Script????

😄
Labels (1)
0 Kudos
(4) Replies
RobertDickau
Flexera Alumni

Some quick questions and impressions:

You'll want a double backslash in the InstallScript string (as you would in C): "C:\\filename.msi".

Do any of the functions return a nonzero value?

Does changing the SQL query to this make any difference:

DELETE FROM `Property` WHERE `Property`.`Property`='MyProperty'

...?

There seem to be two identical calls to MsiViewExecute; perhaps there should be a call to MsiViewFetch and MsiViewModify?
0 Kudos
ishielduser11
Level 3

Hi,


nr_res = MsiOpenDatabase("C:\\MyProg.msi", MSIDBOPEN_DIRECT, hDatabase);

if(nr_res == ERROR_SUCCESS) then
MessageBox("OK",1 );
endif;

nr_res = MsiDatabaseOpenView(hDatabase, "DELETE FROM Property WHERE Property = 'MyProperty'", hView);

if(nr_res == ERROR_SUCCESS) then
MessageBox("OK",1 );
endif;

nr_res = MsiViewExecute(hView, NULL);

if(nr_res == ERROR_SUCCESS) then
MessageBox("OK",1 );
endif;

nr_res = MsiViewClose(hView);

if(nr_res == ERROR_SUCCESS) then
MessageBox("OK",1 );
endif;

nr_res = MsiDatabaseCommit(hDatabase);

if(nr_res == ERROR_SUCCESS) then
MessageBox("OK",1 );
endif;


I've go five times message "OK", so command seems to bee ok. I try to change SQL query "DELETE FROM `Property` WHERE `Property`.`Property`='MyProperty'" but it wolden help. Does anyone have some sugestions??

P.S.

For example in Perl everythings works fine.

P.S. 2

In LogFile is something like this (RemoveProperty is CustomAction name):

MSI (c) (F0!9C) [10:01:11:053]: Leaked MSIHANDLE (34) of type 790540 for thread 1948
Action ended 10:01:11: RemoveProperty. Return value 1.
0 Kudos
RobertDickau
Flexera Alumni

Is this code in an MSI project? The MSI help says that MsiDatabaseCommit can't be called from a custom action, so perhaps that has a bearing on the issue?
0 Kudos
DLee65
Level 13

Why use an InstallScript custom action for this instead of a set property custom action?

If you use a set property custom action you can simply say MyProperty = {} and that will delete the property. It is far simpler, unless of course you are trying to modify an existing MSI package on the user's machine?

Also, the DELETE command will not work on the currently running database if memory serves me correctly, however, I cannot find the documentation to backup this memory. 🙂
0 Kudos