coreybutler / nvm-windows

A node.js version management utility for Windows. Ironically written in Go.
MIT License
36.97k stars 3.29k forks source link

using nvm with blocked VBScript engine #383

Open AllainPL opened 6 years ago

AllainPL commented 6 years ago

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?

coreybutler commented 6 years ago

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.

chawyehsu commented 6 years ago

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.

AllainPL commented 6 years ago

@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?

chawyehsu commented 6 years ago

@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.

coreybutler commented 6 years ago

@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.

rbuckton commented 4 years ago

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>
rbuckton commented 4 years ago

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.

Jasonlhy commented 3 years ago

The way node version manager works is to create a symbolic link:

C:\Program Files\nodejs <========> C:\Users\[myuser]\AppData\Roaming\nvm\[version]

To set the symbolic link manually, you can run the following commands (with admin right): And make sure you understand what is going on ...

cmd /C rmdir "C:\Program Files\nodejs"
cmd /C mklink /D "C:\Program Files\nodejs" "C:\Users\myuser\AppData\Roaming\nvm\v12.22.6"