如何使用 squirrel.windows 创建注册表项

Mau*_*ter 6 javascript electron squirrel.windows

我正在创建一个 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;
  }
}
Run Code Online (Sandbox Code Playgroud)

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

Chi*_*ang 0

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