How to append to the PATH variable in Visual studio 2013 - windows

I want to append a value to my PATH environment variable. I thought this should be easy but its not working in the Developer Command Prompt for VS2013. I have tried the following commands:
set PATH = C:\temp;%PATH% //No quotes
set "PATH = C:\temp;%PATH%" //Quotes around everything
set PATH = "C:\temp;%PATH%" //Quotes only around the value
set PATH = "C:\temp;"%PATH% //Quotes around the new value to be appended
I have looked online and everyone seems to suggest the first or the second option above but when I
echo %PATH%
I dont see C:\temp in the PATH variable.
Any help is appreciated. I am on windows 7 and I work in python but needed to install quantslib. So, I have to go through visual studio.

The environment block is captured when a process starts, which means that Visual Studio won't see the updated path unless you restart it.
Editing the path from the command prompt is possible, but this is the easier way to modify an environment variable:
Right Click on "My Computer"
Click on "Properties"
In the Left-Hand Column, Select "Advanced system settings"
Click on the "Environment Variables..." button.
Under "System variables" select the "Path" variable, then click "Edit...".
Edit the path to your heart's content, then click "OK"
Press "OK" on the two open dialogs. If any program that's currently running needs this path, you'll have to restart that program. If you want to be really sure that everyone has the new PATH values, reboot the computer.

Related

Why are "Path" Windows's environment variable and the command line different?

On my Pc, running Windows XP 5.1.2600, following
"My Computer" > "Properties" > "Advanced" > "Environment Variables" > "Path"
I get a string, but in a batch file, or directly typing from prompt, by means of
echo %path%
I get a different one.
Can someone, please, explain what makes them differ and how to fix the issue, setting the "DOS-path" to the same value of "Windows-PATH" ?
Two things:
As others have mentioned, the full value of PATH is the combination of the user's PATH variable and the system's PATH variable.
If you change environment variables (including PATH), any processes already running (including the Command Prompt) will continue using the old environment variable values. You will need to restart those processes to pick up any changes that you've made.
The value of the PATH environment variable you see on the command line (which has nothing to do with "DOS" btw) is the sum of the system wide PATH variable and the user specific PATH variable.
If you open the dialog with the system variables from within the control panel, the upper part contains the user specific environment variables. The lower part contains the system variables.
If you set a PATH variable for your user to e.g. c:\foo, and the system path is be c:\Windows\System32 then you'd see c:\Windows\System32;c:\foo when you do an ECHO %PATH% on the commandline.
Probably the difference you are seeing is that when a new process is made, its default environment contains a PATH variable that is made by merging the system variable with the user variable.
As for how to "fix the issue", there is nothing to fix. The system behaves as designed.
I was getting the same issue where the System Variable that I get through the
"My Computer" > "Properties" > "Advanced" > "Environment Variables" >
"Path"
was different that the one being displayed through the command line interface via
ECHO %PATH%
The fix for this is basically to wait for the change to take place and this can be made faster by restarting the cmd and explorer. To do that you can simply end task for Explorer and CMD and then start a new task or restart it directly.
The same shall be done for the CMD as well.
The Windows registry can hold path entries that do not show up in the Environment Variables version of PATH you see via the control panel. (Why, I do not know).
The difference means that something (likely an install script) made changes to the registry.
To view or change the local user's path variable, look in the HKEY_CURRENT_USER\Environment key.
To view the system path, look in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment

javac is not working even after setting the path in windows xp

Friends I couldn't access java in my xp even after i set the path
i set the path as set path="C:\Program Files\Java\jdk1.7.0_25\bin"
It doesn't work in xp But it is useful in my windows 7 System
Don't know why
Please answer me
I also set path variable in the environment variables tab.But that doesn't worked for me
Still my javac command says javac is not recognised external or internal command.
So please help me
Run this command in Command Prompt/CMD
set path="%path%;c:\program files\java\jdk1.7.0_25\bin"
If you already have a instance of terminal opened, you'll have to close it and re-open for work. Make sure this path C:\Program Files\Java\jdk1.7.0_25\bin is valid and has javac.
1>First check if java is really installed in your PC.
You can do this by going to
C drive->Program Files->Java
Inside java you should have two folders
1. jdk
2.jre
2> copy the path C:\Program Files\Java\jdk1.7.0_25\bin
(jdk1.7.0_25 is the jdk version you have installed as you mentioned)
3>Go to advanced system settings and click on Environment variables
4>Click on new and you will have two fill the variable name and variable value.
type in " PATH " (without the double quotes and in CAPS) in the variable name
and paste the copied path in the variable name field.
5>Now open a new command prompt and type javac.
You should see a list and not the error you mentioned.
Another way..but this way is only a temporary solution since once you close cmd you will have to set path again.
You can even set path= (paste the path you copied after the equals sign)
First follow these steps
Start -> Control Panel -> System -> Advanced
Click on Environment Variables, under System Variables, find PATH, and click on it.
In the Edit windows, modify PATH by adding the location of the class to the value for PATH.
If you do not have the item PATH, you may select to add a new variable and add PATH as the name and the location of the class as the value.
Close the window.
Reopen Command prompt window, and run your java code.
now Run where java. this should return java path up to java.exe
If still you are having issues leave a comment

Permanently Change Environment Variables in Windows

I found a way to change the default home directory of a user but I am having trouble with it.
Doing this will change the home drive to C:
But then when I check the environment variable:
It is still H:, with a system restart the Enviroment variables in windows settings will also return to H:/
I have also tried changing it like this:
Which appears to work but if i open a new cmd it will have reverted back to H:/
Now I am trying to do this so that OpenSSH will recognise C as my home directory instead of H: which is a network drive, forcing OpenSSH not to work unless I cam connected to my university network via VPN.
What can I do to set this permanently and in the eyes of OpenSSH?
Nowhere does it mention a dependency between the HOMEDRIVE value and the HOMEDIRECTORY value, what was happening (I think) is that it was failing to map the home directory to the HOMEDRIVE and therefore defaulting back to a safe value (C:)
I wrote a script to update the local AD, replace the values in [] with your values. Copy and paste into a .vbs file and double click on it to run it.
Set objUser = GetObject("WinNT://[COMPUTERNAME]/[USERNAME],user")
objUser.homeDirDrive = "H:"
objUser.HomeDirectory = "[URNPATH]"
objUser.SetInfo
e.g.
Set objUser = GetObject("WinNT://UQBDART-2328/BEN,user")
objUser.homeDirDrive = "H:"
objUser.HomeDirectory = "\\SERVER\SHARE"
objUser.SetInfo
run this, reboot and test. It worked for me.
Sounds like the AD profile on the domain is overwriting the user defined variables. I see your screenshot says you are connected to the eait.org.edu.au domain. That will be the root of your issue. Just to include some details here that I spotted elsewhere, that may be of help to you:
HOMEDRIVE, HOMEPATH & HOMESHARE are set and updated via Active Directory. HOMEDRIVE & HOMEPATH are set even without a home drive set on the account; however they will be overridden by any user account properties set in AD.
Also see these KB articles:
http://support.microsoft.com/kb/841343
http://support.microsoft.com/kb/237566
http://support.microsoft.com/kb/101507
On a side-note for another way around the issue:
-I have in the past created a new instance of the windows command-line shell executable that automatically runs a custom script, so everytime you launch the shell, the environment variable could be overriden.
-To do that you could just put the code you posted to change the environment variable into a batch script, stored wherever you like, then edit the shortcut(s) used to launch the shell by going to properties > then alter the Target box: %SystemRoot%\system32\cmd.exe /K "C:\Documents and Settings\Administrator\My Documents\customshellscript.cmd" (Obviously the part of the path after /K is the location of your custom script)
This way, if you are using openSSH over the console anyway, it will always have the homedrive set correctly.
Changing those environment variable's values is not "supported", at least it will not work as you expect because Windows changes them back.
According to this Microsoft knowledge base article (KB841343), you should use policies, if you need to change these settings. The article also contains links for how to do that (but personally, I never tried). Note that the article was originally written for Windows 2000, but I would strongly suspect, that it is still valid for current Windows versions.
Back in the days of DOS the environment variables were part of the Program Segement which meant that you basically got a local snapshop of the variables limited to the scope of that program.
I'm guessing Windows hasn't changed this and the environment variables available to the CMD window only have the scope of that window and any further windows it spawns. This is supported by this little experiment:
in a CMD window type
set homedrive=h:\
and then test it's updated by typing
set h
from this same window type
start cmd
and in this new window type
set h
when I've done this I get HOMEDRIVE=H:\
if I then just open a new CMD window from the start menu and do the same SET H I get HOMEDRIVE=C:\
I don't know anything about OpenSSH but I suspect like the START CMD got the updated HOMEDRIVE environment variable, if you write a batch to update the environment variable and then execute OpenSSH that'll work.
I had a similar issue, the HOMEDRIVE variable was set to U: which was a drive we no longer used. This was just for one particular user. I went to that user's profile in AD and clicked the Attribute Editor tab. There was an attribute for HOMEDRIVE which I changed from U: to C: - when the user logged in again, it was set correctly. I also updated the HomeDirectory attribute here.
This issue had been really frustrating me trying to find a solution, but I have found what I think is the definitive answer and posted it at:
https://stackoverflow.com/a/60235759/12903197
You need to run 'net user USERNAME /homedir:PATH' where USERNAME is the name of the user you are trying to change and PATH is the drive letter and full path to the desired home folder, which must already exist.
On windows 8:
Hit "windows key".
type "system environment variables".
Allow "Advance system settings" to make changes.
Select "Advance" tab.
Click on "Enviroment Variables...".
Double click on "Path" from "User variable for XXXXXXXX"
Add at the end the variable the new path that you want separated by semicolon.
e.g. C:\Program Files\;C:\Python27\
shareeditdelete (1)flag

Problem to access java.exe

Hy!!
My Problem is that my terminal doesn't know the command java.
So i will solve the problem to access the java.exe directly.
Code:
'C:\Program Files\Java\jre6\bin\java.exe' -blabla
Exception:
Wrong Syntax
Please help
For your terminal to recognize command java you must put the entry C:\Program Files\Java\jre6\bin\ in your Environmental Variables in the variable called PATH.
To do so on Windows:
Right mouse click on "My Computer" and select "properties"
Go to Advanced tab
In "Advanced" click on button "Environmental Variables"
In "System Variables" edit PATH entry adding ; to the last entry
Save and restart terminal
EDIT: To run it like you want you should use " instead of '. So your command will look like:
"C:\Program Files\Java\jre6\bin\java.exe" -version
You probably need to add the path to the installed JAVA code to your enviroment PATH variable. This will allow you to just type java.exe at the command line and have it find the executable without needing the full path. Then you could type java -help to see the options available.

Adding a Application specific paths, so it works from the command line in Windows

Following the guide from Microsoft,
http://msdn.microsoft.com/en-us/library/ee872121(VS.85).aspx , I am able to get my program to be able to make a program resolve the dynamic libraries that are required in order for it to work.
So I add a value with the full name and path to my executable, and add subkey to this entry (named path) with the full path the directory of the DLL files.
And magic. It works. I go the start menu, and types myprogram.exe and it starts up and is now able to locate the dll files correctly.
However, if I start the command prompt using the command cmd.exe, and then try to run myprogram.exe is not able to resolve the DLL's anymore. For some reason the command prompt do not seems to respect/read the values of the registry when it is set under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths
Any suggestion to how I can get this behavior to work from within the command prompt as well as from the start menu?
It is correct. HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths is used by ShellExecuteEx and not by CreateProcess. So not all programs will use the settings from App Paths of your application. If you want to define PATH for cmd.exe you can either use subkey of App Paths with the name cmd.exe or use an old %SystemRoot%\System32\autoexec.nt file to modify PATH environment variable.
It's also possible to use "START /WAIT app.exe" from command line which uses ShellExecuteEx.
I'll give it my best shot.
First, notice that both the cmd & the run\start menu options are running everything in C:\WINDOWS\system32.
If you're dll was there then it would work.
if you don't want to put it there, you can change the "environmental variables" by clicking right mouse button on "my computer"-> "properties" -> "Advanced" -> "environmental variables".
good luck.

Resources