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.
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..
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
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)
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
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
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