Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the location of nw.exe? #1197

Closed
DineshDevaraj opened this issue Oct 12, 2013 · 5 comments
Closed

How to get the location of nw.exe? #1197

DineshDevaraj opened this issue Oct 12, 2013 · 5 comments

Comments

@DineshDevaraj
Copy link

I tried process.cwd() but I'm getting some weird location : C:\Users\Dinesh\AppData\Local\Temp\nw2300_31612
nw.exe is at the location : C:\Users\Dinesh\Programs\Node-Webkit\Package

why is this difference in the paths and how can I get the location of nw.exe?

@xdenser
Copy link

xdenser commented Oct 12, 2013

 path.dirname(process.execPath);

@Subash
Copy link

Subash commented Oct 13, 2013

Node-Webkit extracts the *.nw file to the temporary directory so that temporary directory is the current working directory. You can use side by side packaging method to keep the working directory to the folder where nw and package.json file resides.

As @xdenser has mentioned you can use

var path = require('path');
var nwPath = process.execPath;
var nwDir = path.dirname(nwPath);

@DineshDevaraj
Copy link
Author

how to do the side by side packaging?

@Subash
Copy link

Subash commented Oct 13, 2013

Putting the package.json file and nw.exe in same folder without compressing.

@dragonjet
Copy link

sorry for necro'ing an almost 3-year old thread, but it seems there still isn't a way of getting the source of the exe without side by side packaging, so building upon @Subash's code, we can do:

var path = require('path');
var nwPath = process.argv[0];
var nwDir = path.dirname(nwPath);

then nwDir should be the one the user originally opened, not the unpacked one from temp folders

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants