cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
anom217
Level 8

InstallScript function error

I'm working on a Basic MSI project and have created an InstallScript function Custom Action. Here is the code for it

if(ConfigFileLoad("C:\\Program Files\\myprogram\\config.properties") < 0) then
MessageBox ("Unable to load", SEVERE);
abort;
endif;
if(ConfigAdd("Workstation Name", "mycomputer", "", BEFORE) < 0) then
MessageBox("Unable to add", SEVERE);
abort;
endif;
if(ConfigFileSave("") < 0) then
MessageBox ("Unable to save", SEVERE);
abort;
endif;


The error message pops up when I call ConfigAdd. I'm not sure why this is happening though, I've looked at the reference pages for the config functions and this should be right. What am I doing wrong?

I should also note the config file doesn't exist and is being created by this function.
Labels (1)
0 Kudos
(7) Replies
Holger_G
Level 10

Can you please give some more details like:
-Operating system
-Error message content
-custom action type and sequence

It could be a write permission issue since you try to write to C:\Program Files which is a UAC protected folder on Vista and later. If so you should read this document.
0 Kudos
anom217
Level 8

I'm using Windows XP Pro SP2.

I placed the custom action after "Write Ini Values" in the execution sequence, it's a deferred action and the execution schedule is set to "Always Execute". The MSI type is 66560.

The error message I get is the message statement I posted above in my code; that the config value couldn't be added and then the installation aborts. If I leave out this conditional check and abort call, the installation succeeds but the config file is never created in the directory I specified. I tried using the MSI Debugger tool, and in the execution script that's created my custom action is listed there.

I still have no idea why this isn't working. Does anybody know?
0 Kudos
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

What format is the file you are loading with ConfigFileLoad? The Config functions are expecting a text file formatted similar to an ini file (key=value pairs, basically). Errors updating the file with ConfigAdd are likely due to an unexpected format that can't be parsed by the Config functions.
0 Kudos
anom217
Level 8

The file hasn't been created yet, but according to what I've read, ConfigFileLoad should create the file if it doesn't exist, correct? It's a .properties file, and it will be in key=value pairs.
0 Kudos
anom217
Level 8

I'm still having this problem, anyone else have any ideas? This seems like a basic thing, and there is only 3 lines of code. I'm not sure where I'm going wrong.
0 Kudos
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

It appears that the documentation is incorrect for ConfigFileLoad with reference to creating a new file. While ConfigFileLoad will succeed when passed the name of a file that does not exist, subsequent calls to functions such as ConfigAdd will then fail if the file did not exist. These functions have had this behavior since at least InstallShield Professional 7 (and likely earlier versions also).

I have submitted work order IOA-000053573 to have the documentation for ConfigFileLoad corrected.

To have the ConfigAdd call succeed, please ensure the filename passed to ConfigFileLoad exists (you can create an empty file if needed with CreateFile and CloseFile).
0 Kudos
anom217
Level 8

okay, thanks a lot. i've been struggling over this and keep looking at the documentation and could not figure out what I was doing wrong.
0 Kudos