Unable to open a file as argument with an NWjs app on Windows

Affected OS and NW.js version

Windows 7, 8
Any NW.js version since v0.10.3 (september 2014)


Unable to make an NW.js application that open files on Windows (or to pass a filepath as first argument).

The official specification (Handling files and arguments) is outdated or does not work as described in Windows. No newer specification discuss this functionality.
This issue has already been reported many times #2416 #4951 #2525
Since then no fix has been given, despite it’s an essential function for any desktop application.

How to reproduce

Create two files named “package.json” and “app.html” inside a folder named “app.nw” :

  • package.json
  "name": "Test",
  "main": "app.html",
  "version": "0.1.0",
  "description": "Test App"
  • app.html
    /* As described on https://github.com/nwjs/nw.js/wiki/Handling-files-and-arguments */
    var gui = require('nw.gui');
    gui.App.on('open', function(cmdline) {
      document.write('command line: ' + cmdline);

Then package your app using for instance nwjs-builder : nwb nwbuild app.nw

Finally, right-click any file on your computer, then click “Open with…” and select the previously build Test.exe
Result : nothing happens (app crash on loading).

You can also try the command line : .\Test.exe credits.html
The app will crash on loading if the file “credits.html” exists, but works well otherwise.

Author: Fantashit

1 thought on “Unable to open a file as argument with an NWjs app on Windows

Comments are closed.