4

I started a remote session from VM host(desktop) to the guest VM having a Nano server(preview 5). I would like to update the PATH variable and make it effect machine wide(example: to put dotnet.exe in PATH to enable running portable apps). What I am noticing is that the SetEnvironmentVariable overload doesn't have the overload which takes in the target(like 'User', 'Machine' etc.).

If you notice I have the overload in my host's Powershell (the version is a bit older than the Nano server one) but not on the Nano server's one.

In my Nano server: enter image description here

In my VM host(desktop) enter image description here

What am I missing?

Kiran
  • 56,921
  • 15
  • 176
  • 161

2 Answers2

4

This is due to the fact that Nano server uses a stripped down version of .NET called .NET Core. (More info on MSDN.)

The documentation for the Core implementation of SetEnvironmentVariable is available here.

EDIT 26 Sept 2017:

This answer applied to .NET Core 1.x. In .NET Core 2.0, the overload the OP was looking for has been added. The documentation for 2.0 is here.

charleswj81
  • 280
  • 2
  • 6
2

You can use the command setx to set the environment variables

tire0011
  • 1,048
  • 1
  • 11
  • 22
  • Setting variable with setx works just fine, but setx does not allow to remove a variable. At least the Microsoft recommended way (https://support.microsoft.com/en-us/kb/195050) did not work for me, I got "invalid syntax" error. I had to use PowerShell: `Remove-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager\Environment' -Name CATALINA_HOME` – Kirill Kovalenko Sep 09 '16 at 13:08