Unable to open a file as argument with an NWjs app on Windows
See original GitHub issueAffected OS and NW.js version
Windows 7, 8 Any NW.js version since v0.10.3 (september 2014)
Issue
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
<html>
<body>
<script>
/* As described on https://github.com/nwjs/nw.js/wiki/Handling-files-and-arguments */
var gui = require('nw.gui');
document.write(gui.App.argv);
gui.App.on('open', function(cmdline) {
document.write('command line: ' + cmdline);
});
</script>
</body>
</html>
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.
Issue Analytics
- State:
- Created 7 years ago
- Comments:11 (5 by maintainers)
Top GitHub Comments
This is fixed in git and will be available in the next nightly build.
This fixes the problem I had. Thanks!