# \[Windows specific\] Updating registry key from a WebExtension when this one is downloaded from Internet

**URL:** <https://discourse.mozilla.org/t/windows-specific-updating-registry-key-from-a-webextension-when-this-one-is-downloaded-from-internet/16266>\
**Category:** Development\
**Created:** [June 13, 2017, 8:10am UTC](https://discourse.mozilla.org/t/windows-specific-updating-registry-key-from-a-webextension-when-this-one-is-downloaded-from-internet/16266 "2017-06-13T08:10:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bertrand\_perret](https://avatars.discourse-cdn.com/v4/letter/b/5fc32e/32.png) [@bertrand\_perret](https://discourse.mozilla.org/u/bertrand_perret)\
**Post date:** [June 13, 2017, 8:10am UTC](https://discourse.mozilla.org/t/windows-specific-updating-registry-key-from-a-webextension-when-this-one-is-downloaded-from-internet/16266/1 "2017-06-13T08:10:11Z")

</div>

Hi,

Maybe this is a silly question, but I submit it though just to be clear.

Is it possible to update the Windows registry from a WebExtension (i mean from a background script) ?

I would like my background.js to create the HKCU\software\Mozilla\NativeMessagingHosts\<app\_native\_name\> key  
and set the default value to JSON app path

Then launch the native app …

The problem may occur when the webextension is downloaded from a web site …

If there is no needed key in registry, I am pretty sure the webextension won’t work at all.

Thanks for your pointers.

Regards.

---

<div class="post-metadata">

**Author:** ![yfdyh000](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/yfdyh000/32/30581_2.png) [@yfdyh000](https://discourse.mozilla.org/u/yfdyh000)\
**Post date:** [June 13, 2017, 7:02pm UTC](https://discourse.mozilla.org/t/windows-specific-updating-registry-key-from-a-webextension-when-this-one-is-downloaded-from-internet/16266/2 "2017-06-13T19:02:46Z")

</div>

Maybe this is a silly answer (I haven’t studied for native messaging), why does not modify it from the native app?

---

<div class="post-metadata">

**Author:** ![bertrand\_perret](https://avatars.discourse-cdn.com/v4/letter/b/5fc32e/32.png) [@bertrand\_perret](https://discourse.mozilla.org/u/bertrand_perret)\
**Post date:** [June 13, 2017, 9:04pm UTC](https://discourse.mozilla.org/t/windows-specific-updating-registry-key-from-a-webextension-when-this-one-is-downloaded-from-internet/16266/3 "2017-06-13T21:04:07Z")

</div>

Hi,

Thanks to reply.

the pity is that the key mentioned in my post is actually used to launch  
our native app.

It is a prerequisite for launching native apps.

To conclude, I think the only way is to build an installer that will do the job :

- installing the native app
- setting the registry key linked to that app

Regards

---

<div class="post-metadata">

**Author:** ![yfdyh000](https://sea1.discourse-cdn.com/flex001/user_avatar/discourse.mozilla.org/yfdyh000/32/30581_2.png) [@yfdyh000](https://discourse.mozilla.org/u/yfdyh000)\
**Post date:** [June 13, 2017, 10:06pm UTC](https://discourse.mozilla.org/t/windows-specific-updating-registry-key-from-a-webextension-when-this-one-is-downloaded-from-internet/16266/4 "2017-06-13T22:06:08Z")

</div>

Yes, I think the prerequisite for native messaging is that the user manually executes the installer.
