Keep changes to INI when program is uninstalled

Got a problem you cannot solve? Try here.
Post Reply
jmorwick
Posts: 5
Joined: Wed Jul 06, 2011 8:27 am
Location: Prescott Ontario Canada

Keep changes to INI when program is uninstalled

Post by jmorwick »

Hi,

My application is a client/server database application. During the install I copy a default settings INI file to the $TARGETDIR$, I then edit the server ip and port values in the INI with variables I collect from a custom dialog. Everything works great on the install :)

The problem I am having is that the unistall removes the lines I have edited from my INI file even-though the INI file is set not to remove on uninstall. How do I get the Unistall to leave the lines in the INI file? I don't want to have the users reenter these values with each update to my program.
Thanks,
Jamie
giaviv
Posts: 2039
Joined: Fri Dec 17, 2010 1:39 pm

Re: Keep changes to INI when program is uninstalled

Post by giaviv »

Hi Jamie,

That is an interesting question. What you could do is copy the file to a different location (backup), and then restore it to the original folder upon uninstallation..
Aviv Giladi
InstallAware Software

White Papers (HowTos) - http://www.installaware.com/publication ... papers.htm
Product Guides - http://www.installaware.com/publication ... guides.htm
InstallAware Help -F1 anywhere in the InstallAware IDE
jmorwick
Posts: 5
Joined: Wed Jul 06, 2011 8:27 am
Location: Prescott Ontario Canada

Re: Keep changes to INI when program is uninstalled

Post by jmorwick »

Aviv

I placed the code to copy the ini file to the windows\temp folder before the APPLY Uninstall, but the files never get copied to the Windows\temp folder :( . Any suggestions? Here is my code

Code: Select all

if Variable REMOVE Equals TRUE
  Comment: Uninstall product
  Comment: TO-DO: Insert any additional uninstall commands here
  Set Variable TiniExistsTEA10 to 
  Set Variable TiniExistsServerTools to 
  Set Variable TiniBackupExistsTEA10 to 
  Set Variable TiniBackupExistsServerTools to 
  Comment: Before Uninstall
  Does File Exist $TARGETDIR$\TEA 10\TEA.ini (get result into variable TiniExistsTEA10)
  Does File Exist $TARGETDIR$\TEA Server Tools\TEA.ini (get result into variable TiniExistsServerTools)
  if Variable TiniExistsTEA10 Equals TRUE
    Copy Local Files $TARGETDIR$\TEA 10\TEA.ini to $WINDIR$\Temp\TEA_TEA10.bak
    MessageBox: Here 1, TEA.ini backed up from TEA 10
  end
  if Variable TiniExistsServerTools Equals TRUE
    Copy Local Files $TARGETDIR$\TEA Server Tools\TEA.ini to $WINDIR$\Temp\TEA_ServerTools.bak
    MessageBox: Here 2, TEA.ini backed up from TEA Server Tools
  end
   
  Apply Uninstall (get result into variable SUCCESS)
Thanks,
Jamie
bokkie
Posts: 767
Joined: Sun Feb 08, 2009 6:30 am

Re: Keep changes to INI when program is uninstalled

Post by bokkie »

Jamie,

I'll look at one of my installation scripts when I get into work tomorrow. I'm doing exactly what you need to do. I have a dialog that reads the ini file if it exists and displays the default values if the file does not. When I uninstall I leave the file on disk, so the existing values are picked up if you reinstall later. It works 100% for me. Let me review the code and I'll update with what I'm doing unless somebody chimes in with a solution before then.
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP
bokkie
Posts: 767
Joined: Sun Feb 08, 2009 6:30 am

Re: Keep changes to INI when program is uninstalled

Post by bokkie »

Jamie,

My approach was very simple. Once I've gathered the details from the dialog and set a flag to see if the file exists or not I let the install do its thing. Then, after the Apply Install has been done, I then switch to native engine mode and I then copy the file if needed first, and then I do the edit to the ini file. I then switch off native engine mode and that's about it. I copy the file after the apply install in native engine mode as that sort of ensures that no uninstall of it takes place when uninstalling. Works for me. :)
Peter. Smartly dressed, he still resembles an unmade bed.
InstallAware MVP
jmorwick
Posts: 5
Joined: Wed Jul 06, 2011 8:27 am
Location: Prescott Ontario Canada

Re: Keep changes to INI when program is uninstalled

Post by jmorwick »

Peter,

Your solution for keeping changes to my ini file works like a charm :). Now to figure out how to read the ini and populate the ip variables from the imported ini file :)
Thanks,
Jamie
Post Reply