6

我正在创建一个 Electron 应用程序,并且正在使用 electron-winstaller 来构建使用 squirrel.windows 的安装程序。在其中一个示例代码片段中包含以下部分:

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;
  }
}

在上面的部分中,“- 写入注册表以获取文件关联和资源管理器上下文菜单等内容。”。我想在此处添加注册表项,但是在查看 squirrel 文档时,我不知道如何执行此操作。我在网上找不到任何例子。有人有想法么?

4

1 回答 1

0

Squirrel 不会公开命令来更改注册表,因此您必须自己编写。spawnReg这个 CoffeeScript 中有一个例子: https ://gist.github.com/Hrxn/7f415e5e32abb83eff27

于 2021-02-12T02:34:29.163 回答