I already added the following snippet to my package.json
:
"build": {
"fileAssociations": [
{
"ext": "asdf",
"name": "ASDF File",
"role": "Editor"
}
]
}
But the generated installer does not assign my application to the asdf
extension. (tested on Windows 10)
I also looked up, how to edit the setupEvents.js
file. It contains the following part:
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
But I could not find a single example, how to archieve the registry writing part.
In the Control Panel, click the Default Programs option. Click the Associate a file type or protocol with a program option. In the Default apps window, scroll to the bottom and select Choose defaults by file type. Find the file type that interests you.
It's impossible to create a single executable file of an electron application. The application's source code is available to anyone. No ways to protect the application's assets (scripts, images, etc.) No ways to set the executable file icon.
Electron is a framework that allows you to develop native cross-platform desktop applications based on HTML, JavaScript and CSS. It uses Chromium to render the content and Node. js to access the local file system and the operating system. That allows you to create a Windows or Mac application with local file access.
To distribute your app manually, you need to download Electron's prebuilt binaries. Next, the folder containing your app should be named app and placed in Electron's resources directory as shown in the following examples. The location of Electron's prebuilt binaries is indicated with electron/ in the examples below.
Add the "perMachine": true,
option, e.g.:
"build": {
"fileAssociations": [
{
"ext": "asdf",
"name": "ASDF File",
"role": "Editor",
"perMachine": true
}
]
}
The reason it is needed, is because on Windows, per-user installed program cannot register file associations, and that is the default setting.
It seems that with the newer version you need to set it like this
"build": {
"fileAssociations": [{
"ext": "ext1",
"name": "ext1 File",
"role": "Editor"
},
{
"ext": "ext2",
"name": "ext2File",
"role": "Editor"
}
],
"nsis": {
//othersettings,
"perMachine": true
}
}
there is more information about other file association settings here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With