Nvm-windows: using nvm with blocked VBScript engine

Created on 23 Aug 2018  ·  7Comments  ·  Source: coreybutler/nvm-windows

Hi, i have a question. I have a computer that has blocked VBScript engine by domain policy. Is it possible to run nvm? Because even with elevated command prompt(or PS) i stil get the info about the missing script engine. Is there a workaround to use nvm without it?

Most helpful comment

Also, if you install nvm-windows with the NodeJS path set to a user-local folder (such as %USERPROFILE%\AppData\Local\nodejs), you can switch to junctions and skip elevation by replacing the contents of %USERPROFILE%\AppData\Roaming\nvm\elevate.cmd with the following:

@setlocal
@echo off
set CMD=%*
REM Old 'elevate.cmd' commands...
REM set APP=%1
REM start wscript //nologo "%~dpn0.vbs" %*

REM New 'elevate.cmd' commands...
%CMD:mklink /D=mklink /J%

This executes the command without elevation, replacing mklink /D with mklink /J to create directory junctions instead.

All 7 comments

Unfortunately, there's no way to do this. The VBScript runs the elevation command, which is required to symlink node into the file system.

I would be open to PR's if someone has an alternative. The ideal situation would be to embed this into the Go app, but I haven't had enough time to explore this.

I have a fork that totally remove the whole elevated permission part, use junctions for symlink. As a restricted user, this works fine for me. You could try my build to see if that help, but there is only noinstall build.

And FYI, actually, there is an old issue tracking about NTFS junctions here.

@h404bi Thanks for the code! I get a Exit Code 5: Access Denied - however when running in elevated cmd - it works(the vba is not used anymore).

@coreybutler do you have any opinion what direction you will be going, considering #79?

@AllainPL
If you have something that located in C:\Program Files/C:\Program Files\nodejs or other path which needs elevated permission, it will still need a elevated cmd.

settings.txt

root: C:\Users\<omitted>\path\to\nvm-windows\nodejs
arch: 64
proxy: none

I use nvm in user-space, which means all my nvm and node stuffs are stored in my %USERPROFILE%, no need to access C:\Program Files, so I could manage all my things with a normal restricted user, without vbscript, without UAC pop-up. I use it on my WIndows 7 SP1 and Windows 10 machines.

But this all means that I couldn't mange the system-wide installed nodejs, I think it's ok for me, I don't have system-wide installed nodejs , just use that one in my user-space, all things good.

@AllainPL - my leaning is towards making the symlink type configurable as a setting. However; this would most likely be a 2.X.X feature, so no immediate ETA. Once I release Fenix 3, I should have alot more time to focus on the next release.

BTW: If the user has PowerShell installed, you can possibly avoid using VBScript for a UAC prompt using the following command line instead:

powershell -NoLogo Start -Verb:RunAs -Wait -FilePath:<executable> -ArgumentList:<args>

Also, if you install nvm-windows with the NodeJS path set to a user-local folder (such as %USERPROFILE%\AppData\Local\nodejs), you can switch to junctions and skip elevation by replacing the contents of %USERPROFILE%\AppData\Roaming\nvm\elevate.cmd with the following:

@setlocal
@echo off
set CMD=%*
REM Old 'elevate.cmd' commands...
REM set APP=%1
REM start wscript //nologo "%~dpn0.vbs" %*

REM New 'elevate.cmd' commands...
%CMD:mklink /D=mklink /J%

This executes the command without elevation, replacing mklink /D with mklink /J to create directory junctions instead.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

eliavmaman picture eliavmaman  ·  6Comments

snerte picture snerte  ·  5Comments

thany picture thany  ·  4Comments

petrovicz picture petrovicz  ·  4Comments

tomByrer picture tomByrer  ·  4Comments