Matthew Beermann

Bug in Custom Actions

There seems to be a new bug in Custom Actions that wasn't there before 1.4:

If you have an action that runs the installed application at commit, it picks the wrong working directory to start the program from. I'm not sure where it's putting it, but it ought to be TARGETDIR for me and there's no way to specify.
Cata
Posts: 638
Joined: Thu Apr 10, 2003 7:37 am
Contact: Website

Hi Matthew,

Please clarify a little bit:
1) Is the custom action found and started correctly? If it is,
2) What working directory do you get instead of TARGETDIR?

Thanks,
Cata
Catalin Rotaru - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Matthew Beermann

Details

1) Yes, the application starts correctly.
2) I'm not sure what directory it's in, but it can't locate any of its settings files, or even its icon, because it looks for those in its own directory (being a Java application).

This behavior only happens when the app is started by the installer. If I exit it and restart from the installed shortcuts, everything works perfectly...
Cata
Posts: 638
Joined: Thu Apr 10, 2003 7:37 am
Contact: Website

Hi Matthew,

I am afraid that in Windows Installer there is no way to specify the working directory for custom actions. The behavious from the previous versions was a side-effect of some other WI operation...

But you don't have to depend on the working directory for your app's operation. In Win32 you can use GetModuleFileName() to get the path to the EXE file. In Java you can find out the JAR's path with URL url = getClass().getClassLoader().getResource("com/mycomp/myapp/MyClass.class");

And in WI you can author a registry entry with [TARGETDIR] as value and then read it from your program (with Prefs in Java).

Notes:
a) In 1.4 you can specify the java product's icon in the defined product itself and it will be embedded in the EXE file.
b) In 1.5 you'll have the ability to start the installed application after the installation with a built-in custom action triggered from the UI.

Regards,
Cata
Catalin Rotaru - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”