You are here

Registry Overwriting

7 posts / 0 new
Last post
PaperProjects
Offline
Last seen: 10 years 6 months ago
Joined: 2012-09-17 18:28
Registry Overwriting

I've looked around the forums, and generally it can be seen that PortableApps Launcher handles the registry in a few steps.

When the application is launched, it checks if there is anything existing in the targeted registry key and backs it up, then the portable app will write its own key in. When the application is closed normally NSIS has the time to backup the written registry key and restore the original key.

However, if NSIS is terminated, then the registry is not handled correctly and the app will clean up on next startup.

All of your portable registry settings would be deleted, right?

I'm not entirely clear on this, but when you run a PortableApps launcher, in Task Manager there will be two entries.

application.exe
ApplicationPortable.exe

Where does NSIS come in, and I want to know which one can be terminated safely and which one, if terminated will cause issues.

darksabre76
darksabre76's picture
Offline
Last seen: 2 weeks 1 day ago
Developer
Joined: 2011-04-19 23:28
Answer

In your example, ApplicationPortable.exe is the NSIS created launcher that handles the PortableApps.com-specific options. If you do have to terminate one of the programs, terminate application.exe because ApplicationPortable.exe will detect that it has closed and perform the shutdown procedures for that app. I hope this helps you.

tapsklaps
Offline
Last seen: 5 years 6 months ago
Developer
Joined: 2010-10-17 08:11
correct order

Fundamentally it's very important, that in Task Manager you firstly terminate the application.exe and afterwards the ApplicationPortable.exe (= launcher) and not conversely. The reason for this order lies caused in the fact, that only in this case the launcher is able to perform the steps, which I described in detail in handling of the registry by the launcher (see especially the steps 6 - 10 after the closure of application.exe).

But if you firstly close the launcher, then the following scenario might be performed. Assuming that on the host PC is installed a local copy of an application, which we want call example_app. Example_app stores its settings in example_app.reg. If we now start the portable version of example_app, the launcher creates a backup of the file example_app.reg and afterwards deletes the file example_app.reg (see the steps 1 and 2 of my above mentioned instructions). After this procedure was created a new file example_portable_app.reg. If you now firstly terminate the launcher instead of example_app.exe itself, then the steps 6 - 10 can't be performed correctly. That means, that it's impossible to restore the previously created backup of the file example_app.reg. Insofar the file example_portable_app.reg is still available in the registry after the closure of the portable version of example_app. That means, that at the next run of the locally installed version example_app will use now the settings, which are stored in the file example_portable_app.reg (and not the settings, which are stored in the file example_app.reg).

PaperProjects
Offline
Last seen: 10 years 6 months ago
Joined: 2012-09-17 18:28
Loss of Data?

Thanks to both of you for replying: The application must be closed before the launcher. However, as described by tapsklaps, are you saying that failing to close the launcher properly results in the deletion of the local application's registry entries? The loss of such data could result in the loss of important information such as configuration and product activation.

Or is there any safety precautions with the result, that at the next run of the portable app the correct settings will be restored?

The launcher should delete pertinent registry entries and appdata on the next launch, since it displays the "cleaning up" and rerun popup.

-PaperProjects Professional

tapsklaps
Offline
Last seen: 5 years 6 months ago
Developer
Joined: 2010-10-17 08:11
more detailed analysis

Let us consider the processes in more detail. For this consideration we assume, that the launcher was terminated first and afterwards the file application.exe, i.e. in the false order. We want again use for the further explanations our example application named example_app.exe. Due to the incorrect order of termination we find in the registry the settings, which are stored in the file example_portable_app.reg. But in fact you must find in the registry the settings, which are stored in the file example_app.reg.

If we now rerun the launcher, then the launcher normally tries to perform the steps 1 and 2 of my instructions. Accordingly the launcher would create a backup of the file example_portable_app.reg. But this procedure is incorrect. Instead the launcher must recognize, that for the last time the steps 6 - 10 of my instructions wasn't performed correctly. That means, that the launcher must necessarily remember at the created backup of the file example_app.reg, which he has stored before the incorrect termination. Therefore the launcher doesn't need to create a new backup at the rerun. By this way is now the launcher able to restore the correct backup of the file eample_app.reg. By this procedure it's now possible, that the appropriate settings of the locally installed version of the app was restored correctly.

PaperProjects
Offline
Last seen: 10 years 6 months ago
Joined: 2012-09-17 18:28
Thanks, I understand now.

I see, if detected the incorrect closing of the launcher the launcher will use procedure A1 instead of A. Otherwise, A1 would be skipped. Thanks

A. [Launch Procedure]
1. Back up app.reg
2. Import app_portable.reg to registry

-A1. [Recovery Procedure(Incorrect Closure)]
1. Back up app_portable.reg
2. Restore app.reg to registry
3. Requires relaunch to A.

B. [Close Procedure(Correct Closure)]
1. Back up app_portable.reg
2. Restore app.reg to registry
3. Delete app.reg from PortableApps directory

-PaperProjects Professional

tapsklaps
Offline
Last seen: 5 years 6 months ago
Developer
Joined: 2010-10-17 08:11
further considerations

There are different possibilities by which it might happen, that the correct order of termination of application.exe can't be observed (for example a crash of the PC). Does this necessarily mean, that in such a case some stuff will remain on the host PC? Or is there any safety precautions with the result, that at the next run of the portable app the correct settings will be restored?

Log in or register to post comments