Page 1 of 1

Keep changes to INI when program is uninstalled

Posted: Wed Jul 13, 2011 1:42 pm
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.

Re: Keep changes to INI when program is uninstalled

Posted: Wed Jul 13, 2011 6:01 pm
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..

Re: Keep changes to INI when program is uninstalled

Posted: Thu Jul 14, 2011 2:37 pm
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)

Re: Keep changes to INI when program is uninstalled

Posted: Thu Jul 14, 2011 2:45 pm
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.

Re: Keep changes to INI when program is uninstalled

Posted: Fri Jul 15, 2011 1:15 am
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. :)

Re: Keep changes to INI when program is uninstalled

Posted: Fri Jul 15, 2011 1:31 pm
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 :)