How do I get a persisted variable from previous install?

Got a problem you cannot solve? Try here.
Post Reply
JohnO
Posts: 127
Joined: Tue Jun 18, 2013 9:52 am

How do I get a persisted variable from previous install?

Post by JohnO »

When I install a new version of an existing app, the uninstall-before-install processing somehow knows where the current version is installed, and uninstalls it from there. How does it know the location of the current version?

The reason I ask is that I have a new variable called USERWORKSPACE, which I persist. If I explicitly uninstall the current app, the value that the user chose is saved and used again (in the same way that $TARGETDIR$ is known).

However, when I am installing a new version 'over' an existing one, i can see from debug MessageBoxes, that neither TARGETDIR nor USERWORKSPACE have been set to their values that were persisted in the old setup. This suggests that the current value of TARGETDIR is persisted somewhere else - the Registry? If it is, could you give me a clue as to where to look in the MSIcode to see it saved and recovered. I need to do something similar for USERWORKSPACE

Regards, John
FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: How do I get a persisted variable from previous install?

Post by FrancescoT »

Dear John,

Please have a look at the following topic;
http://www.installaware.com/forum/viewt ... f=2&t=1734

Anyway, I am sure there are available even more topic about the same argument on the forum.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
JohnO
Posts: 127
Joined: Tue Jun 18, 2013 9:52 am

Re: How do I get a persisted variable from previous install?

Post by JohnO »

Dear Francesco
I have used Save Feature to persist my USERWORKSPACE and other values into AppData\$PRODUCTCODE$\ia_memento.txt.
However I am stuck when it comes to getting them back! I expected Load Feature to populate any persistent variables that were already defined from the saved text file. However when I display values after the Load, TARGETDIR = it's default value, and USERWORKSPACE is empty.

In the help for Load Feature Selections, it says:
Selection states will be ignored for all features not explicitly defined in the setup script using the Define Component command by the time the Load Feature Selections command executes in the script.
My trouble is that I don't understand what I am supposed to define here, and how it relates the Load Feature Selections - there is no reference in the Save or Load command to a feature.

I added a Define Component for my 'root' feature, then loaded my txt file. This made no difference. It seems to me that I need a command to load and extract the variables that I need.

Are there any examples of saving and getting the persistent variables in this way. I seem to be so close...

[edit:
I found someone having exactly the same problem back in May:
http://www.installaware.com/forum/viewt ... f=2&t=9467
But that ended without a resolution. I seems to me that there is a need for an example of how to code this (save and retrieve), but it doesn't seem to exist. Could you or someone provide example of the code statements?
]

Regards, John
JohnO
Posts: 127
Joined: Tue Jun 18, 2013 9:52 am

Re: How do I get a persisted variable from previous install?

Post by JohnO »

I've now come to the conclusion that the easiest way to achieve this is to save and read the values in an ini file.

However, given that there looks to be a lack of info on how to use Load Feature Selection, it would be very helpful if this thread could be completed by some guidance.

John
FrancescoT
Site Admin
Posts: 5361
Joined: Sun Aug 22, 2010 4:28 am

Re: How do I get a persisted variable from previous install?

Post by FrancescoT »

Dear John,

did you follow the correct way to do it?

Anyway, place the following SAMPLE code at the very beginning of your main script.

Code: Select all

Load Feature Selections from file c:\test.state
Set Persistent Variable MYVAR to $MYVAR$
if Variable MYVAR Equals 
  MessageBox: Debug, Package not installed yet or never installed, so set persistent variable MYVAR.
  Set Variable MYVAR to $SFXPATH$
  Save Feature Selections into file c:\test.state
else
  MessageBox: Debug, Loaded  MYVAR value = $MYVAR$.
end
The same as clipboard format.

Code: Select all

~InstallAware Clipboard Data~
~End~
~{391C39DF-B428-45DF-8237-297ED16E5BE5}~
~MessageBox~
~{D9C19182-C641-46C2-AEEB-EDF9F353E79D}~
~Debug~
~Loaded  MYVAR value = $MYVAR$.~
~0~
~1~
~~
~Else~
~{006F5604-7A98-4DCA-BE72-F17A0DFAF96B}~
~Save Feature Selections~
~{64504B9C-FD0E-43C8-9605-F680364DD58B}~
~c:\test.state~
~Set Variable~
~{653A4CCD-26D4-4E05-8C9F-FF70D0077F7F}~
~MYVAR$MYAH$MYAH$FALSE~
~$SFXPATH$~
~MessageBox~
~{A65ECAF9-A95B-405B-BCD6-EAA41FCAE549}~
~Debug~
~Package not installed yet or never installed, so set persistent variable MYVAR.~
~0~
~1~
~~
~If~
~{07DF9E3E-3B2E-4192-9F89-300C6912CC14}~
~MYVAR~
~0~
~~
~FALSE~
~Set Variable~
~{2292EF7D-DD37-440F-B6CD-9CAD1A566EBF}~
~MYVAR$MYAH$MYAH$TRUE~
~$MYVAR$~
~Load Feature Selections~
~{4F74AED4-FB82-4B20-BE8C-5826F02D2CC2}~
~c:\test.state~
Hope this helps you.

Regards
Francesco Toscano
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Publications - http://www.installaware.com/publications-review.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
Post Reply