Node: Add script files association in Windows installer

Created on 19 Apr 2016  路  10Comments  路  Source: nodejs/node

Windows has not shebangs, but file associations can do the thing.

Perl and Python installers both have the appropriate option:

perl

python

They add some keys to the Windows registry for this.

After that users can write, for example, script.pl arg instead of perl script.pl arg. In addition, they can just click on the script icon if script arguments are not needed.

Users of other interpreters get used to it. After they start using Node.js they feel the lack of this feature. There is no easy solution on the user end: the bunch of proper registry keys are not simple or well-known, and association via context menu is not well for argument handling (see my former frustration in this pseudo-issue: https://github.com/nodejs/node/issues/4725 ). However for the developers of the installer to add this feature seems not so difficult. It could be added to any major or minor version without any chance to break something.

May be it would be a nice present for windows users on the occasion of Node.js v6.0 release?

feature request install windows

All 10 comments

@rusco But for this to work user still needs either to use context submenu each time ("Open with...") or bind file extensions with Node mannualy via system dialog (with "Always use..." checked).

It's just a workaround. I am not 100% sure whether I created a default association or not, at least now it works on the command line, just calling my "script.js".

I'm for it. The only issue I have is that .js is by default already associated to Windows Scripting Host, but I guess that's considered legacy by Microsoft nowadays. Probably should make it off by default for that reason.

@nodejs/build

/cc @nodejs/platform-windows

My reservations are related to @silverwind's comments about .js already being a _thing_ in Windows. Although, I think Firefox (and Mozilla / Netscape before it) was hijacking .js on Windows at one stage wasn't it? Does it still do it?

My reservations are related to @silverwind's comments about .js already being a thing in Windows.

It would be optional, so why not?

This could be dangerous. Just a quick search on my hard drive shows a tons of .js files under Program Files and Windows folders, that are not Node.js scripts. And it's impossible to know what this might break.

I am -0 on whether this should be in the MSI (though I am slightly concerned about the possible support issues coming our way). Certainly, it should never be on by default.

FWIW, it might not be necessary to set things in the registry directly to accomplish this; Windows has commandline actions to create or update file associations:
http://ss64.com/nt/assoc.html
http://ss64.com/nt/ftype.html

On the other hand, the registry might allow for more fine-grained control. I'm not sure whether those commands change the current user's setting, or the default setting for all users, or if it depends whether it's run as admin or something.

This issue has been inactive for sufficiently long that it seems like perhaps it should be closed. Feel free to re-open (or leave a comment requesting that it be re-opened) if you disagree. I'm just tidying up and not acting on a super-strong opinion or anything like that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cong88 picture cong88  路  3Comments

willnwhite picture willnwhite  路  3Comments

seishun picture seishun  路  3Comments

mcollina picture mcollina  路  3Comments

stevenvachon picture stevenvachon  路  3Comments