Just like the title i want to keep and old file i am about to replace and then if the customer ever runs the uninstaller the old file will get replaced. I could not find this topic so that is why i started this new topic. Thanks.
Announcement
Collapse
No announcement yet.
Saving old file and replacing it after uninstall
Collapse
X
-
To answer your question, use the appropriate File.Copy() action in On Pre Install and another File.Copy() in On Post Uninstall.
However, I suspect that you are talking about configuration files for flight simulator software, and while replacing a backup during uninstall sounds good, this is not how you should do it. Your setup should insert the required entries in the configuration file, and the uninstall should remove the inserted elements / values. You should not assume that the end user did not install anything else after your product was deployed. If you simply return the configuration file before your setup started, then all changes done to the configuration file after the setup - removal of add-ins or installation of other features - will be lost and the environment will be broken. Instead, as I mentioned, remove the entries of your product(s) and preserve anything else done.
Ulrich
-
I think using the XML.insertXML will not be good if the customer did edit the config file. Because then if we look for entries like in my example here [fltsim.1] they may not match anymore by the time we uninstall. What we want is to take what ever they have now and give them a complete new list. Then they have the option to edit it afterwards. Then if they ever uninstall we again want to revert back to the default entries we gave them. And again they can edit afterwards. Nobody is going to uninstall and keep the lear without the expansion pack anyways. But just incase this prevents them from re installing the lear again if they do uninstall the expansion pack.
So i will try the first method. But if i ever do need to use the second method would love to know with these type of entries as each entry ends with the same info. So i posted a sample [fltsim.1] is the last entry and i may want to add lets say 5 more entries. Can you share some code to look for the file and add the info please?
[fltsim.0]
title=Learjet 35A N31WS
sim=Learjet35A
model=
panel=
sound=
texture=N31WS
kb_checklists=Learjet35A_check
kb_reference=Learjet35A_ref
atc_id=N31WS
atc_airline=Lear
ui_manufacturer="Gates"
ui_type="Learjet 35A"
ui_variation="N31WS"
ui_typerole="Corporate Jet"
ui_createdby="Flysimware"
description="Learjet 35A"
Comment
-
This file uses the INI file format, so you would use the INIFile actions to update the contents of this file. For a few customers, I wrote code which inserts a section into the next available position, I assume you also do this. Upon uninstall, instead of looking for a certain number, you would parse the sections of the INI file and detect the one which corresponds to your product, and then remove that section, keeping every other information in the configuration file intact.
Ulrich
Comment
-
I have decided to go with plan A.
Using File.Copy for Pre Install works greatas i used the sample from the SDK. But no matter how many different methods i use for the File.Copy uninstall i get the error message "There was an error copying the files to your system. Please try again."
I am confused. Here is the uninstall code i use in the post uninstall.
The file i need i had created in a folder called "Copied Files" from the uninstall.exe location. So this way the _SourceFolder can find it. But i have a feeling the _SourceFolder is only for installer.exe. So I also tried using a direct path but still same error. i cam use some help for sure on this one.
Code:-- Get the path to the user's main install directory. DestFolder = ("%AppFolder%"); File.Copy(_SourceFolder.."\\Copied Files\\*.*", DestFolder.."\\Simobjects\\Airplanes\\FLYSIM Learjet 35A\\", true, true, false, true, nil); -- Check to see if the File.Copy action failed by getting it's error code. error = Application.GetLastError(); StatusDlg.Hide(); -- If it failed (not equal to 0), display a dialog informing the user. -- If it succeeded, open an explore window showing the "Copied Files" folder. if error ~= 0 then result = Dialog.Message("Error", "There was an error copying the files to your system. Please try again.", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1); else Shell.Execute(DestFolder.."\\Copied Files", "explore", "", "", SW_SHOWNORMAL); end
Comment
-
Thanks Ulrich for all the help. I solved the issue on my last question.
The _SourceFolder needed to be the _TempFolder as i now save the file in folder called Copied Files from the users temp folder. And now i can tell the original file to not uninstall so that way i can just use the pre uninstall to overwrite so that way the temp file can delete files no longer needed.
Comment
Comment