最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to associate a file extension to an electron app (multiplatform) - Stack Overflow

programmeradmin3浏览0评论

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.

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.

Share Improve this question asked Nov 29, 2018 at 8:56 kroegeramakroegerama 88912 silver badges29 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 9

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

发布评论

评论列表(0)

  1. 暂无评论