Can't remove %PATH% variable? - command-line

I'm using Windows 10.
I somehow added a variable to %PATH% in the command line (I don't remember how), and it now shows up when I type echo %PATH%. However, when I go to the GUI Environment Variables, that certain variable appears neither in the Path of "User variables for [my_username]" nor the Path of "System variables".
How do I find where I can edit %PATH% and remove the variables I need to remove?

You most certainly used "set" to change a environment variable for the current cmd.exe. The change does only affect the currently running cmd.exe process.
see also: https://ss64.com/nt/set.html

Related

GNU Make ignores environment variables on windows

So, in powershell, I type
$ Set-Variable FOO
Then, in my makefile, I have
.PHONY: show-foo
show-foo:
#echo ${FOO}
It outputs a blank line.
I've tried using system variables like $profile, none of the environment variables seem to be passed into the makefile.
can someone tell me what I'm doing wrong here?
On windows 10, using make 4.2.1
Set-Variable sets a shell variable, but does not modify the environment (just like var="val" in sh without exporting would). Instead use
$env:FOO="VALUE"
to manipulate the environment.

How can I set environment variables in fish?

I'm new to the fish shell, and just trying to set my $EDITOR variable so that's it's persistent across sessions and reboots. Here's what I've tried so far:
Running set -gx EDITOR vim from the command line.
Running set -Ux EDITOR vim from the command line.
Running those commands, prefixed by set -e EDITOR to unset any previous value.
Adding the above commands to my ~/.config/fish/config.fish file (it complains set: Warning: universal scope selected, but a global variable “EDITOR” exists.)
Uninstalling oh-my-fish and removing all fish configs to start from scratch.
No matter what I do, the EDITOR variable always ends up being /usr/bin/nano whenever I open a new terminal, start a new session, or reboot. What's even more strange is that in ~/.config/fish/fishd.my-hostname, I see SET_EXPORT EDITOR vim, and nothing about nano. Is this some kind of fish default? If so, how can I set this correctly?
Edit: I'm running Fish 2.6.0 on Antergos Linux.
First, the fish config file is ~/.config/fish/config.fish. Editing the file you named won't have any effect. Second, fish does not have any default for, nor does it set, the EDITOR or VISUAL variables. So whatever is setting it to /usr/bin/nano is a customization unique to your system.
If you set -Ux EDITOR vim and do not set it in config.fish it should be set to vim even if it is already set when fish starts. Run that set command then do set -U | grep EDITOR and env | grep EDITOR to see that it is set as a universal variable and exported. Now type fish to start a sub-shell. Run the previous two commands and you should see that it is still set to the same value. Now type set -U EDITOR nano in the sub-shell followed by exit. In the earlier shell you should now see that EDITOR is set to nano.
Personally I don't like to use uvars for this since at the moment they are per-machine. I just do set -gX EDITOR (type -p vim) in my ~/.config/fish/config.fish. This ensures that if I start fish on a new machine on which I've installed my ~/.config/fish directory I get my expected defaults.
The other reason not to use a uvar in this way is that the resolution order is local scope, global scope, universal scope. Since environment vars imported when fish starts running are placed in the global scope they will shadow the uvar you defined. Do not export universal variables. It is unlikely to produce the desired results. Simply set -gx the var in your config.fish script.
P.S., When asking questions of this nature you should always include pertinent facts such as the OS you're using and the fish version.

$env:PSModulePath versus %PSModulePath%

How comes cmd.exe shows different values for PSModulePath than PowerShell does?
PowerShell:
\\share\user\WindowsPowerShell\Modules;
C:\Program Files\WindowsPowerShell\Modules;
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
CMD:
C:\Windows\system32\WindowsPowerShell\v1.0\Modules\
The environment variables seems to be modified 'localy' at execution ( changes are not saved to the system ).
Running cmd from within the powershell console should work as you expect :
PS>cmd /c echo %psmodulepath%
Anytime you start up PowerShell it will create a set of environment variables for that session. These can all be found under the $env (ex. $env:PSModulePath). There is a set of default values that go here. These default values are hard corded but you can of course modify those default values by changing it in one of the profile script locations.
As for CMD.exe, whenever it starts up it too will create environment variables, however it's environment variables are pulled from the OS environment.
Go to Control Panel -> System -> Advanced Settings -> Advanced Tab -> Environment Variables

Add environment variable to install4j

Is it possible to add environment variable to install4j once, instead of add this variable under the "Specify environment variable" field?
for example i want to add JAVA_VENDOR=Sun once and each time i will use "Run executable or batch file" action this variable will be recognized by the running process.
Thanks in Advance,
Maxim
Yes you can do it with setx command.
See setx /? for more info.
Setx "JAVA_VENDOR" "Sun once"
PD: Remember the CMD uses the set profile at this moment, I mean if you try to ser a voiremental variable directly in a CMD instance you'll need to close and re-open cmd to see the changes.
Bye.

Why is the Powershell Environment PATH different to the System Environment PATH?

I'm having this weird situation :
My user's and system's PATH variable is different than the PATH in powershell.
When I do :
PS C:\$env:path
C:\Windows\System32\WindowsPowerShell\v1.0\;c:\oldpath
However this is not correct, it looks like it stuck on some old PATH variable of my system, so none of the udpates I've done on it didn't change this variable (I do restart after every change to test).
Why is this happening? Do I have to set a PATH variable just for powershell?
The change might be "delayed", so try one or more of these solutions:
Log off and on again;
Task Manager > Restart "Windows Explorer" (explorer.exe)
Restart your launcher app (launchy, SlickRun, etc)
Reboot
Explanation:
Powershell will inherit the environment of the process that launched it (which depends on how you launch it). This is usually the interactive shell (explorer.exe). When you modify the environment from computer properties, you modify the environment of explorer.exe, so if you launch powershell from explorer.exe, (for example from the start menu) you should see the new environment.
However, if you launch it from something else (say a cmd.exe shell that you already had opened), then you won't since that process was launched under the old environment.
In other words: be careful how you are launching things.
In my case, I installed an app that incorrectly added itself to the PATH by creating a powershell profile that would override $env:PATH and blow out the existing configuration every time I started powershell.
Check if you have profile at USER\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 and if it's doing anything fishy like setting $env:PATH.