Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uninstall Cleanup #836

Open
red-game-dev opened this issue Apr 4, 2024 · 0 comments
Open

Uninstall Cleanup #836

red-game-dev opened this issue Apr 4, 2024 · 0 comments
Labels
Priority: 4 - Low Severity: 3 - Low Minimal impact, typically cosmetic issues or minor bugs affecting a few users. Type: Enhancement New feature or request

Comments

@red-game-dev
Copy link
Contributor

red-game-dev commented Apr 4, 2024

We will need to implement cleanup after uninstallation, generally the uninstall needs to clean up the following:

Windows:

  • Registry
  • Any data files left around in DATA folder

Linux:

  • Should be by default all removed, as it works as rm -rf

MacOs

  • Why do you make life harder? We need to ask the user to cleanup manually

What brought the issue?

  • This issue was found after implementinghttps://github.com/HyperPlay-Gaming/product-management/issues/142, which been there since the beginning
  • This is the issue that relates & may require this current issue first before we go to this https://github.com/HyperPlay-Gaming/hyperplay-store/issues/105, why? Because even after implementing serverside we may still face this issue, regardless ans registry is not cleanup and normal cleanup still required.

Why do we need the above?

If we keep up the registry or any form of files, that means there won't be any clean install and may some issues persist. One of the issue did is the URL SCHEME Protocol, this will remain in the registry therefore when user tries with the new CTA to Play/Install Game if the launcher was once installed, and than uninstalled, it will by default think it is still installed and it breaks as unable to find the application

How to handle this on Windows?

For Electron apps packaged with Electron Builder, when you're working with custom NSIS scripts like build/customUninstall.nsh, you need to place these scripts in a location where Electron Builder can find them during the build process. The typical approach is to create a directory within your project structure dedicated to build configurations and scripts. Here's how you can organize it:

Create a Directory for Build Configurations: Inside your Electron project's root directory, create a folder named build. This is a conventional name, but you can choose another name if you prefer.

Place customUninstall.nsh in the Build Directory: Move or create your customUninstall.nsh script inside the build directory. This script contains your custom NSIS commands for handling uninstallation cleanup, as discussed.

Reference the Script in package.json: In your package.json file, under the build section, specifically within the nsis configuration, you need to reference the path to customUninstall.nsh relative to the project root. Assuming you've placed the script in the build directory as suggested, it would look something like this:

"build": {
  "appId": "com.yourcompany.yourapp",
  "nsis": {
    "include": "build/customUninstall.nsh"
  },
  "win": {
    // Other Windows-specific configuration
  }
}

This setup tells Electron Builder to include and execute your custom NSIS script during the installation process. It's a neat way to ensure that your app cleans up after itself upon uninstallation, especially for custom URL schemes and other system-level changes your app might make.

The content example of the .nsh

!include "MUI2.nsh"

!macro customUnInstall
    DeleteRegKey HKCU "Software\Classes\hyperplay"
    DeleteRegKey HKCU "Software\Classes\hyperplay\DefaultIcon"
    DeleteRegKey HKCU "Software\Classes\hyperplay\shell"
    DeleteRegKey HKCU "Software\Classes\hyperplay\shell\open"
    DeleteRegKey HKCU "Software\Classes\hyperplay\shell\open\command"
    DeleteRegKey HKCR "hyperplay"
!macroend

Elctron-Builder: https://www.electron.build/configuration/nsis.html


There is more to this, the testing part requires you to build the actual app, install and uninstall and check the registry everytime

If is root (All Users)

reg query HKEY_CLASSES_ROOT\hyperplay

If single user

reg query HKEY_CURRENT_USER\Software\Classes\hyperplay

While through script as below:

const { exec } = require('child_process');

const scheme = 'hyperplay';
const command = `reg query HKEY_CLASSES_ROOT\\${scheme}`;

exec(command, (error, stdout, stderr) => {
  if (error) {
    console.error(`Error: ${error}`);
    return;
  }
  if (stderr) {
    console.error(`Error: ${stderr}`);
    return;
  }
  if (stdout) {
    console.log(`${scheme} URL scheme is registered.`);
  } else {
    console.log(`${scheme} URL scheme is not registered.`);
  }
});
@red-game-dev red-game-dev self-assigned this Apr 4, 2024
@red-game-dev red-game-dev added Type: Enhancement New feature or request Priority: 4 - Low Severity: 3 - Low Minimal impact, typically cosmetic issues or minor bugs affecting a few users. labels Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: 4 - Low Severity: 3 - Low Minimal impact, typically cosmetic issues or minor bugs affecting a few users. Type: Enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant