Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

setting IFX_PRODUCT_ICON


17 replies to this topic

overlordchin

overlordchin
  • Full Members
  • 100 posts

Posted 23 March 2011 - 16:01

cut and paste from my post on the flexera forums:

So we have an installscript project which does not have an icon for add remove programs. I would like to add one. I started searching for how to do so and came across the IFX_PRODUCT_ICON variable / registry information in the Install script language reference pdf. However, I cannot find an example of how or where to set this properly.

Can anyone give me an example of what this should look like?

I even found another thread which mentions this as a solution to the same problem but with no details on how to do it. http://community.sof....799#post420799

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 23 March 2011 - 16:52

Did you specify the icon under General Information > Add/Remove Programs?

If you want to set it in script I guess (haven't tried) it would be something like:
IFX_PRODUCT_ICON = SUPPORTDIR ^ "your.ico";
Your .ico file must be added to the support files section.

overlordchin

overlordchin
  • Full Members
  • 100 posts

Posted 23 March 2011 - 18:27

Yes I did try that but see my post below for what i was doing wrong:

So I did not find specifically how to set the variable but I did discover a few other things about Install script projects.

If you set the icon for the add/remove programs under the general information it is ignored if you do it the same way you would in MSI projects. That is to say you are pointing to a location on the machine with IS on it and not a target dir on the machine the software is being installed on. It does not appear to embed the icon in the installer the way an MSI project does.

The icon needs to be copied to the target machine and the path should reflect that. In my test this got the icon to appear in add remove programs

Also see Stefan's comment about the support files as that is a good way to deploy the file. In my case I am actually using a sub installer to deploy it since the installscript project is actually wrapping 2 other installers (ugly but functional)

overlordchin

overlordchin
  • Full Members
  • 100 posts

Posted 24 March 2011 - 14:46

Actually disregard my comment about support files. They are only present during the install. The issue there is that with an install script the icon appears to have to be there all the time in order to appear in the add/remove list.

The problem I am running into is that I can not get something to consistently deploy /read where I expect it to. So if I set something in my install dir which is c:\ProgramFiles\MyCompany\MyProject

and I install on a 64bit machine I get the Program Files (x86) folder instead which is not a problem for my installation. However I have not found a way to make the path for the icon pick up like this. If I set my icon path to be c:\Programfiles\mycompany\myproject it will not look in the x86 version. I tried using the variable [INSTALLDIR] just like that but it didnt work. I also tried [COMMONFILES] which has the same problem.

Is there a way to use a variable there that will look in the proper location everytime?


Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 25 March 2011 - 13:29

Glad you realized that issue with using SUPPORTDIR and instead you'll want to use TARGETDIR as that will reflect the actual installation path for both x86 & x64 OSes.
user posted image

overlordchin

overlordchin
  • Full Members
  • 100 posts

Posted 25 March 2011 - 14:19

I tried setting the display icon in the add remove programs view to be :

[TARGETDIR]\myicon.ico which does not appear to work...

What am I doing wrong?

Edited by overlordchin, 25 March 2011 - 14:19.


overlordchin

overlordchin
  • Full Members
  • 100 posts

Posted 25 March 2011 - 14:36

I have also tried [TARGETDIR]MyIcon.ico
and <TARGETDIR>\MyIcon.ico

How am I supposed to refer to it properly to make it work?
The only way I have consistently been able to get it to work is to make an absolute path and then move the icon there.

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 28 March 2011 - 13:34

The correct InstallScript syntax is as follows:

CODE
TARGETDIR ^ "MyIcon.ico"


If for some reason it's still not working, then please confirm the resulting registry entry and the availablility of the icon file.
user posted image

overlordchin

overlordchin
  • Full Members
  • 100 posts

Posted 28 March 2011 - 14:50

@Taco Bell - The place I have been modifying this is in the add remove programs view not in the Setup.rul file. I do not mind changing it in the setup.rul file but in which method does it need to be changed? I do not need to have an = somewhere? Seems like there should be something infront of the TARGETDIR ^ myico.ico like IFX_PRODUCT_ICON = TARGETDIR ^ myico.ico

Sorry if I am being too literal in my interpretation of your post. Is there a way to do this in the add remove view area? Or does it need to be in the script? If so where do I change it(see above question)?

Thanks for all of your input so far. It is appreciated.


*** EDIT ***

I tried putting it in the

function onMoveData()
begin
IFX_PRODUCT_ICON = TARGETDIR ^ "myicon.ico";
end;

and now my installer no longer installs so that was apparently not an appropriate place to put it. NOTE: previously that method did not exist in my rul file so it was going with the default version of this method.




*** 2nd EDIT ***

onBegin() also does not work but does not break the installer like changing onMoveData() does.



*** 3rd EDIT ***

I did also try the same string you suggested in the add / remove programs view under the display icon setting. It did not seem to have any impact on the installer.

I did a search for my icon name and found where it sets display icon in the registry:
the path looks like:
"[ProgramFilesFolder]MyCompany\MyProduct\MyIcon.ico" only with out the ""

It is actually possible that registry key is created by one of the wrapped installers. This script wraps 2 installers into one bundle. The 2nd product is actually hidden from the add/remove programs list and the bundle installer is actually placed there instead. So when you remove the bundle you remove all associated software. Just to complicate matters further: The bundle and the sub product both have the same name and the same icon.

Edited by overlordchin, 28 March 2011 - 15:48.


Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 29 March 2011 - 14:05

I don't normally use the "Add or Remove Programs View", but it appears to only take a hard-coded string, so you will have to do this through your Setup.rul script.

To that end, add the following code to the "After Move Data" | "OnFirstUIAfter" method as that event is triggered after the file transfer for the initial installation:

CODE

function OnFirstUIAfter()
 NUMBER nResult, nvType;
 STRING szARPKey, szARPIcon;
begin
 RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);  
 szARPKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + PRODUCT_GUID;
 nvType = REGDB_STRING;
 szARPIcon = TARGETDIR ^ "myicon.ico";
 nResult = RegDBSetKeyValueEx(szARPKey, "DisplayIcon", nvType, szARPIcon, -1);
end

Hopefully that clarifies things, but let me know if you have any additional questions/problems.
user posted image

overlordchin

overlordchin
  • Full Members
  • 100 posts

Posted 30 March 2011 - 14:20

Thanks for your advice but it did not work. Not only did it not work it broke the installer.
This installer normally calls two other installer projects. Only one actually installs even though both entries show up in the add/remove programs. The icon still does not appear although this time there is a reason. The code causes the 2nd installer to not install for whatever reason and since it does not install there is no folder containing the icon.

I cut and paste your code minus the declaration of the function and begin / end to my OnFirstUiAfter() method.

I do not see anything harmful in your code when I look at it so I am sort of puzzled that it breaks stuff. The only thing I can think of is that nResult is already used but it should not matter. The value gets reset about 5 lines after your stuff when nResult is set = to something else.

Thoughts?

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 30 March 2011 - 23:40

Sorry, but I can't think of any reason why my suggested code would break your installer, so you'll need to step through and debug it.
user posted image

overlordchin

overlordchin
  • Full Members
  • 100 posts

Posted 11 April 2011 - 16:10

Still not sure what is causing the breakage. I have looked into debugging it a little bit. The key actually gets written out like [ProgramFilesFolder] and not c:\Program Files (x86). The registry does not seem to like it being a variable. So TARGETDIR apparently contains another variable?



Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 12 April 2011 - 13:26

The registry certainly needs a static path and TARGETDIR should have the actual installation path without any variable references, so you'll need to further debug your setup.
user posted image

overlordchin

overlordchin
  • Full Members
  • 100 posts

Posted 03 June 2011 - 20:30

Sorry it took me so long to get back to you. I got pulled onto another project. I modified what you suggested and was able to make it work for me. I used the following modified snippet of your code:

CODE

RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);  
szARPKey = "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\" + GUIDHERE;
nvType = REGDB_STRING;
szParameter = "ProgramFiles(x86)";
svValue = GetEnvVar (szParameter,szEnvPath);
                 
szARPIcon = szEnvPath ^ "\\My Company\\MyProduct\\MyIcon.ico";
nResult = RegDBSetKeyValueEx(szARPKey, "DisplayIcon", nvType, szARPIcon, -1);
// end icon code


thankyou so much for your help with this. It is greatly appreciated

Taco Bell

Taco Bell

    IS6 Expert

  • Moderators
  • 1,281 posts

Posted 06 June 2011 - 13:44

Glad you got it working overlordchin and you're welcome.
user posted image

overlordchin

overlordchin
  • Full Members
  • 100 posts

Posted 09 June 2011 - 16:36

@ Taco Bell one last thing.. If I wanted this to happen on upgrade as well. What method could I house this in?

overlordchin

overlordchin
  • Full Members
  • 100 posts

Posted 10 June 2011 - 20:20

I moved it out into its own method and then call it in both OnFirstUIAfter(), and OnUpdateUIAfter() which works for both first installs and upgrades. Thanks again.