windows-installer icon indicating copy to clipboard operation
windows-installer copied to clipboard

Created .exe after installation not working

Open Kugl opened this issue 6 years ago • 4 comments

Hello, I am creating and running the squirrel installer successfully. My Electron app also opens as expected during install. Link on the Desktop is created as desired.

However when I click the link on the Desktop a loading indicator pops up for a second and then nothing happens. If I navigate to the install folder I see a subfolder named app-0.0.0 . Inside this folder is another .exe which works perfectly fine.

I cannot figure out how to get the desktoplink to open the app.

My build script looks like this:

const createWindowsInstaller = require("electron-winstaller")
  .createWindowsInstaller;
const path = require("path");

getInstallerConfig()
  .then(createWindowsInstaller)
  .catch(error => {
    console.error(error.message || error);
    process.exit(1);
  });

function getInstallerConfig() {
  console.log("creating windows installer");
  const rootPath = path.join("./");
  console.log(rootPath);
  const outPath = path.join(rootPath, "");
  console.log(outPath);

  return Promise.resolve({
    appDirectory: path.join(outPath, "CostEngine-win32-x64"),
    authors: "ME",
    noMsi: true,
    outputDirectory: path.join(outPath, "costengine-installer"),
    exe: "CostEngine.exe",
    setupExe: "Installer.exe"
  });
}

In my main.js i integrated:

const { app, BrowserWindow, ipcMain } = require("electron");
const setupEvents = require("./installers/setupEvents");
if (setupEvents.handleSquirrelEvent(app)) {
  // squirrel event handled and app will exit in 1000ms, so don't do anything else
  return;
}

I moved the setup into a seperate file which looks like this (Identical to documentation):

const electron = require("electron");
const app = electron.app;

module.exports = {
  handleSquirrelEvent: function() {
    if (process.argv.length === 1) {
      return false;
    }

    const ChildProcess = require("child_process");
    const path = require("path");

    const appFolder = path.resolve(process.execPath, "..");
    const rootAtomFolder = path.resolve(appFolder, "..");
    const updateDotExe = path.resolve(path.join(rootAtomFolder, "Update.exe"));
    const exeName = path.basename(process.execPath);
    const spawn = function(command, args) {
      let spawnedProcess, error;

      try {
        spawnedProcess = ChildProcess.spawn(command, args, { detached: true });
      } catch (error) {}

      return spawnedProcess;
    };

    const spawnUpdate = function(args) {
      return spawn(updateDotExe, args);
    };

    const squirrelEvent = process.argv[1];
    switch (squirrelEvent) {
      case "--squirrel-install":

      case "--squirrel-updated":
        // Optionally do things such as:
        // - Add your .exe to the PATH
        // - Write to the registry for things like file associations and
        // explorer context menus

        // Install desktop and start menu shortcuts
        spawnUpdate(["--createShortcut", exeName]);

        setTimeout(app.quit, 1000);
        return true;

      case "--squirrel-uninstall":
        // Undo anything you did in the --squirrel-install and
        // --squirrel-updated handlers

        // Remove desktop and start menu shortcuts
        spawnUpdate(["--removeShortcut", exeName]);

        setTimeout(app.quit, 1000);
        return true;

      case "--squirrel-obsolete":
        // This is called on the outgoing version of your app before
        // we update to the new version - it's the opposite of
        // --squirrel-updated

        app.quit();
        return true;
    }
  }
};

Install Folder Looks like this: Screen

I am stuck and any help would be appreciated

Kugl avatar Feb 29 '20 18:02 Kugl

Changed the version to 1.0.0 now it works. However not 100% sure if that was the change that made the difference. Is this working as intended?

Kugl avatar Feb 29 '20 18:02 Kugl

The same thing is happening to me... This is really weird...

Samuel-Martineau avatar Aug 25 '20 22:08 Samuel-Martineau

did anyone find a solution? the same thing happens to me

alexsanderluisdev avatar Jul 29 '22 02:07 alexsanderluisdev

My app version was 1.27.07 and I was getting this error. I changed the app version to 2.0.0 and it's working. Would it be a bug in specific versions of the app?

alexsanderluisdev avatar Jul 29 '22 19:07 alexsanderluisdev