I can imagine a few different ways to get to your goal:
ActiveX and NPAPI plugin are mentioned here - those are very outdated, you dont need to even open that link
[Outdated Answer] Call DLL methods from Javascript
Some collection of other methods:
[Firefox related] How to call user32.dll methods from javascript
[Newer Answer] Call Function from DLL loaded in front-end javascript (load dll in clientside javascript)
[IE only - ActiveX]
https://msdn.microsoft.com/de-de/library/7sw4ddf8(v=vs.94).aspx
And last but not least my favourite and state-of-the-art method: develop a locally running System Tray app or windows service that listens on a port, allowing Cross domain calls and triggers stuff when called using ajax from javascript.
[EDIT]This last option is also cross-platform compatible and pretty portable. For explaination, this "on the client running" windows service could listen on 127.0.0.1:1234 and should just add Access-Control-Allow-Origin:* to any response that it sends, this way you can just use ajax calls to 127.0.0.1:1234 for calling it. You package and distribute it in a downloadable installer package. In your javascript you do a test api call at initialisation to see if the package is installed and available. If not, you present the download link.
If running as tasktray app, you additionally provide an "i already have it, just start it" button and register an app handler in the registry (thats another topic)
In the end if you do not want to go for any kind of compiled application, the number of options fade quickly and you'd need to explain much more around why you want to use javascript only (e.g. is it just because you dont know any other language or so)