- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
当我安装或更新我的 Electron 应用程序时,我试图为其创建快捷方式,但是我在执行用于创建快捷方式的命令时遇到了一些问题。默认情况下,Electron 应用程序是“SquirrelAware”,因此我必须指定要在何处创建快捷方式。
我的问题与这个问题的公认答案有关。
Handle Squirrel's event on an Electron app
我曾尝试使用 exec
模块和 child_process
模块,但是两者似乎都不起作用。我现在正在尝试(但失败了)启动 PowerShell 并在其中运行一个脚本,该脚本将在我的“开始”菜单和桌面上创建快捷方式,但我觉得这相当长,而且必须有更简单的方法。
这是我目前使用 child_process 模块和 PowerShell 的尝试:
var spawn = require('child_process').spawn, child;
child = spawn("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",["C:\\ElectronSquirrelDemo\\AddAppShortcuts.ps1 -SourceExe "+ executionPath] );
child.stdout.on('data', function(data){
console.log("PowerShell Data: " + data);
});
child.stdout.on('data', function(data){
console.log("PowerShell Error: " + data);
});
child.stdout.on('exit', function(){
console.log('PowerShell script finished');
});
如有任何帮助,我们将不胜感激
最佳答案
我自己花了一段时间才明白如何做到这一点。 Squirrel.Windows Update.exe 能够为您创建应用程序的快捷方式。我写了一篇名为 Creating a Windows Distribution of an Electron App using Squirrel 的博文在其中我让 Squirrel 为我创建快捷方式。如果您想走这条路,这是如何让 Squirrel 为您创建快捷方式的简化版本:
var cp = require('child_process');
var updateDotExe = path.resolve(path.dirname(process.execPath), '..', 'update.exe');
var target = path.basename(process.execPath);
var child = cp.spawn(updateDotExe, ["--createShortcut", target], { detached: true });
child.on('close', function(code) {
app.quit();
});
您需要使用 Resource Hacker、rcedit 或其他应用程序破解 electron 可执行文件以更改 ProductName 和 Icon 资源。您需要在安装和更新的 Squirrel 事件中调用上述代码。
关于node.js - 在 Electron 应用程序的 Squirrel 事件中执行 createShortcut,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30784512/
我有以下 NSIS 代码 Function CreateDesktopSC ;Creates Desktop Shortcut SetShellVarContext current
当我安装或更新我的 Electron 应用程序时,我试图为其创建快捷方式,但是我在执行用于创建快捷方式的命令时遇到了一些问题。默认情况下,Electron 应用程序是“SquirrelAware”,因
我是一名优秀的程序员,十分优秀!