rncox73
Posts: 18
Joined: Thu Jun 17, 2010 11:39 pm

Setting a user defined property based on OS version

I would like to detect the OS Version at the start of my installation and then set a user defined property to a specific value. For example if the OS is Windows7 I want to set the value of the property to "ABC" and if the OS is Windows XP I want to set the value of the property to "DEF". This is just an example, but I will use it to store a password to be used elsewhere. For Windows 7 I want to use 1 password and Windows XP a different password. I am having difficulty figuring out how to do that. I tried a scriptinline with a custom action. I've attached a screen shot of that screen.
Attachments
CustomActionScreen.JPG
CustomActionScreen.JPG (107.73 KiB) Viewed 9033 times
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Setting a user defined property based on OS version

Hi,

You can try using multiple Property set with formatted custom actions, one for each possible value you want to use. These custom actions can then be conditioned with VersionNT property.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rncox73
Posts: 18
Joined: Thu Jun 17, 2010 11:39 pm

Re: Setting a user defined property based on OS version

Thanks Cosmin. Will the Property Set with Formatted custom action occur at the very beginning?
rncox73
Posts: 18
Joined: Thu Jun 17, 2010 11:39 pm

Re: Setting a user defined property based on OS version

I need to capture this value before one of my prerequisites run. How can I do that because it doesn't seem to be capturing it that early.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Setting a user defined property based on OS version

Hi,
Will the Property Set with Formatted custom action occur at the very beginning?
Custom actions are executed whenever you schedule them in Custom Actions page. Each custom action is scheduled after a standard action or after another custom action.
I need to capture this value before one of my prerequisites run.
If you are using feature-based prerequisites you can schedule the custom actions after InstalUISequence -> WelcomeDlg standard action. Please note that global prerequisites are handled by an EXE bootstrapper and are not part of your MSI. So you cannot schedule custom actions before they are evaluated.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rncox73
Posts: 18
Joined: Thu Jun 17, 2010 11:39 pm

Re: Setting a user defined property based on OS version

Thanks Cosmin. That worked great.

However I setup another Customer Action --> Property Set with Formatted to store a value in a second user defined property. I put it under InstalUISequence -> WelcomeDlg standard action as well. The condition is exactly the same as the first one so I know that it right but my user defined property doesn't seem to get set. The difference is that I am using this property to set a value in an xml file that gets installed. Does the custom action need to run in a different place? I've attached a screen shot of the edit XML dialog.
Attachments
EditXMLFileScreenShot.JPG
EditXMLFileScreenShot.JPG (40.63 KiB) Viewed 9017 times
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Setting a user defined property based on OS version

Hi,

Please try using a public property (only uppercase letters in its name). Private properties use their default values in InstallExecuteSequence (when XML files are written).

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rncox73
Posts: 18
Joined: Thu Jun 17, 2010 11:39 pm

Re: Setting a user defined property based on OS version

Cosmin: That still didn't work. Does the attached screen shot look correct for my custom action? I've made sure the XML file is using the new public property (all upppercase letters).
Attachments
CustomActionScreen2.JPG
CustomActionScreen2.JPG (96.56 KiB) Viewed 9009 times
mihai.petcu
Posts: 3860
Joined: Thu Aug 05, 2010 8:01 am

Re: Setting a user defined property based on OS version

Hello,

This custom action should execute and set the ENCSQLSAPWD property if you are installing on a Windows 7 machine. Also, it will execute only if the "MSC" feature is installed locally. If this feature is not selected for installation or you're not installing on a Windows 7 machine, the condition will resolve to false.

To test this, you can add a MessageBox custom action which displays the property right after SetEncSAPWD custom action.

All the best,
Mihai
Mihai Petcu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
rncox73
Posts: 18
Joined: Thu Jun 17, 2010 11:39 pm

Re: Setting a user defined property based on OS version

Thanks Mihai. That is definitely the conditions. I will try the message box.

Return to “Common Problems”