Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Windows 8.1 .js file association does not allow passing arguments #9338

Closed
SkyLined opened this issue Mar 5, 2015 · 6 comments
Closed

Windows 8.1 .js file association does not allow passing arguments #9338

SkyLined opened this issue Mar 5, 2015 · 6 comments

Comments

@SkyLined
Copy link

SkyLined commented Mar 5, 2015

Problem

It seems that the Node.js x64 0.12.0 installation on Windows 8.1 adds the following file association with ".js" files to the registry:

HKEY_CLASSES_ROOT\Applications\node.exe\shell\open\command\
"@"=REG_SZ:"C:\Program Files\nodejs\node.exe" "%1"

Unfortunately, this does not allow passing arguments to the script:

C:\>test.js a b c
Arguments: []

Proposed fix

This is easily fixed by modifying the association and add "%*" like so:

HKEY_CLASSES_ROOT\Applications\node.exe\shell\open\command\
"@"=REG_SZ:"C:\Program Files\nodejs\node.exe" "%1" %*

Now if I run the same test, it works as expected:

C:\>test.js a b c
Arguments: ["a","b","c"]
@piscisaureus
Copy link

I don't think the installer does that. Are you sure you didn't add it yourself in the first place?

@SkyLined
Copy link
Author

SkyLined commented Mar 5, 2015

That may be true :( - I did mess up my settings and had Windows automatically associate it. Let me try to undo that damage and see if it fixes this issue.

@SkyLined
Copy link
Author

SkyLined commented Mar 5, 2015

So I reverted to the default, which seems to be .js files are run in wscript.exe. I then reinstalled Node.js, but the association has not changed to Node.js. Is this by design? I assumed Node.js would associate with .js files, so you can easily run them from the command-line.

@AlicanC
Copy link

AlicanC commented Mar 6, 2015

Hah. I was trying this on my second display to see if it worked and I got scared to death when my editor popped up on the other display.

(So I also don't think the installer does something like this.)

Though, the installer can ask if we want a "Run with Node" option in the context menu, just like Sublime Text does. I would say yes to that.

You should close this issue and create a new one as a suggestion. Don't forget to reference it here.

@silverwind
Copy link

I think that association has two meanings:

  1. What happens on double-click
  2. The CLI association (probably the equivalent of a shebang on Windows)

There are some risks to setting it though, as WSH is still in use and we could break other things by setting that association. For the first case, I think silent mode execution would be preferred, there is some discussion about that in nodejs/node#556.

@SkyLined
Copy link
Author

Opened a feature request

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

No branches or pull requests

4 participants