【问题标题】:Using node-cmd module while handling Squirrel Events function在处理 Squirrel Events 函数时使用 node-cmd 模块
【发布时间】:2018-02-16 06:04:36
【问题描述】:

我正在使用electron-packagerelectron-squirrel-startup 为Windows 构建一个桌面应用程序,我想在安装我的应用程序期间执行一些Windows cmd 命令。为此,我计划使用node-cmd 节点模块,但我并没有真正在handleSquirrelEvents 函数中工作。像这样的示例命令:

function handleSquirrelEvent(application) {  
const squirrelEvent = process.argv[1];
    switch (squirrelEvent) {
       case '--squirrel-install':
       case '--squirrel-updated':
          var cmd=require('node-cmd');
          cmd.run('touch example.created.file');
    }
};

似乎有效。在 my_app/node_module/node-cmd/example 目录下创建了一个文件 example.created.file。

但是任何其他代码都不起作用。即使我只更改要“触摸”的文件名,也不会发生任何事情。

【问题讨论】:

    标签: node.js cmd electron node-modules squirrel.windows


    【解决方案1】:

    好的,example.created.file 已经存在于该目录中,我怀疑您只能在 case '--squirrel-updated' 部分中使用 update.exe 支持的命令。所以这行不通。

    【讨论】:

      猜你喜欢
      • 2015-10-13
      • 2019-04-26
      • 2015-03-24
      • 2017-08-20
      • 1970-01-01
      • 2019-12-28
      • 1970-01-01
      • 1970-01-01
      • 2021-08-01
      相关资源
      最近更新 更多