electron - Electron 安装程序在错误的组中创建快捷方式

标签 electron squirrel.windows

我无法理解在GitHub, Inc.行上创建快捷方式时,squirell安装程序在哪里获取ApplyReleasesImpl: Creating shortcut的值?
SquirrelSetup.log是:

 Program: Starting Squirrel Updater: --createShortcut Arefsotil.exe
 ApplyReleasesImpl: About to create shortcuts for Arefsotil.exe, rootAppDir C:\Users\xxx\AppData\Local\Arefsotil
 ApplyReleasesImpl: Creating shortcut for Arefsotil.exe => C:\Users\xxx\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\GitHub, Inc.\Arefsotil.lnk
 ApplyReleasesImpl: About to save shortcut: C:\Users\xxx\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\GitHub, Inc.\Arefsotil.lnk (target C:\Users\xxx\AppData\Local\Arefsotil\Arefsotil.exe, workingDir C:\Users\xxx\AppData\Local\Arefsotil\app-1.0.0, args , toastActivatorCSLID 72b097c7-3197-528e-bad0-3a09c24db577)

我的build.js是:
var electronInstaller = require('electron-winstaller');

// In this case, we can use relative paths
var settings = {
    // Specify the folder where the built app is located
    appDirectory: '../build/bundle/Arefsotil-win32-x64',
    // Specify the existing folder where
    outputDirectory: '../build/installers',
    // The name of the Author of the app (the name of your company)
    authors: 'Our Code World Inc.',
    // The name of the executable of your built
    exe: './Arefsotil.exe',
    title: 'Arefsotil'
};

resultPromise = electronInstaller.createWindowsInstaller(settings);

 resultPromise.then(() => {
     console.log("The installers of your application were succesfully created !");
 }, (e) => {
     console.log(`Well, sometimes you are not so lucky: ${e.message}`)
 });

和我的app.js松鼠事件:
// this should be placed at top of main.js to handle setup events quickly
if (handleSquirrelEvent(app)) {
  // squirrel event handled and app will exit in 1000ms, so don't do anything else
  return;
}

function handleSquirrelEvent(application) {
  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(application.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(application.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

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

最佳答案

似乎在其中创建快捷方式的组名称取决于 Electron 包装商提供的元数据公司名称值。 Electron 包装机的另一个参数解决了该问题:
'--win32metadata.CompanyName="My Company" '

关于electron - Electron 安装程序在错误的组中创建快捷方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60350123/

相关文章:

electron - 为已安装的 Electron 应用程序创建快捷方式

c# - WPF 应用程序的部署和更新程序

c# - "Update.exe not found, not a Squirrel-installed app"错误中指定的 Update.exe 是什么?

electron - Electron 中包含哪些Node API?

javascript - 如何将文件扩展名关联到 Electron 应用程序(多平台)

javascript - 在 Electron/NodeJS 应用程序中捕获命令行响应

electron - 在electronjs中查找应用程序目录

node.js - Electron-Builder:在MacOS上使用松鼠构建Windows安装程序失败

javascript - 针对Win32 x64编译后,Electron应用程序将无法打开

Electron builder - 未设置 GitHub 个人访问 token ,既不以编程方式,也不使用 env "GH_TOKEN"