Setting default path with custom variable in windows 10pro - windows

I have been trying to get windows to recognize shortcuts for developer tools. Things like adb for C:\Users\myusername\Andriod\platform-tools\adb.exe. I have tried using CMD and Powershell but they both don't add the PATH I tried the GUI and it doesn't show up.
I've tried setx path "%PATH%;C:\path\to\C:\Users\myusername\Andriod\platform-tools\adb.exe" in powershell and cmd then restarted powershell or cmd
input the variable adb but it pulls a command not recognized error.

Did you try the following?
Adding the path "C:\Users\myusername\Andriod\platform-tools" to your system/user PATH variable? You can do this by start-> environment variable -> environment variable and under system or user, edit the PATH variable and add the above link. Once you do this, restart CMD for it to work.
Add the executable in one of the already existing locations that are in the PATH variable. (Although this is one method, I would not suggest this). Again, if the executable has any dependencies, it must be in a place where the exe itself can access.

Related

What is the difference between the PATH listed by 'env' in git-bash and the PATH in Windows 10's control panel?

My goal is to write a shell script that will ensure that a bunch of Windows 10 computers with Python freshly installed on them can run the 'python' command from a git-bash command line in Windows Terminal by having the script check the PATH environment variable and modify it if necessary.
More specifically, I want my script to check if the following three paths are part of each computer's PATH, and if they aren't already a part of it, edit the PATH so that it permanently contains them.
C:\Program Files\Python311
C:\Program Files\Python311\Scripts
C:\Users\ <localUser>\AppData\Roaming\Python\Python311\Scripts
What threw me off is that I noticed that the PATH variable that I get from the 'env' command on the git-bash command line is different from the PATH variable that I can see in Windows 10's control panel. I tried adding a junk path to PATH from the command line by typing
export PATH=/c/someNonexistentPath in git bash but it didn't change the PATH that I could see in the Windows 10 control panel. Moreover, I couldn't even see if it changed the PATH I get from running env on the command line because for some reason after you run any export command git-bash gets amnesia and refuses to recognize the env command until you start a new session of git-bash.
Shouldn't there only be one PATH on a computer? If the two seemingly different PATHs that I have mentioned are not supposed to be the same, what is the difference between them, and how can I accomplish my goal of writing the script so that it does what I need it to do?
Please let me know if I need to include any more system-specific info. Thanks in advance for your help.

Restore the previous system path variable (windows)

a question regarding messing with Windows Path variable.
My situation is quite specific:
I was trying to install ffmpeg according to this tutorial https://www.geeksforgeeks.org/how-to-install-ffmpeg-on-windows/
The last step was setting the path variable setx /m PATH "C:\ffmpeg\bin;%PATH%"
It worked, however afterwards I noticed that if I try to call python from the command prompt or the powershell if run as administrator, I started getting 'chcp' is not recognized as an internal or external command, (although works fine if run as user), indicating that something is wrong with PATH variables.
I looked into my variables and saw this edit.
Path
It seems to me that the command added the ffmpeg line to the system path and possibly overwritten the original, which is why there are issues when using command prompt as administrator. It probably should have added it to the user Path (not system Path variable)
If that is the case, is there a way to restore the previous system Path variable. Maybe I can paste it from the user Path variable?

Can I change the PATH variable for a single window?

I'm trying to set up Code::Blocks on a Windows 7 machine without administrator privileges. I've installed Code::Blocks and MinGW, but I can't edit the user or system PATH variable.
I can open a command line with the required changes to the PATH variable with the following .bat file:
SET PATH=%PATH%;c:\mingw\bin
cmd
If I try to open Code::Blocks the same way, using the following .bat file:
SET PATH=%PATH%;c:\mingw\bin
C:\CodeBlocks\codeblocks.exe
Code::Blocks opens, but the PATH variable is unchanged so it can't compile.
Is there any way to change the PATH variable for a single application? I'd prefer this solution because it can be applicable in other circumstances.
If that's not possible, is there any way to add to the searched PATH in Code::Block's settings?

Windows PATH variable is different if whether running CMD as admin or not

I just installed scala but I can't call it from the command line. So I dutifully checked my path through the environmental variables of the control panel and saw the scala folder present. If I type scala from cmd within that folder, it works fine.
So I tried echo %PATH% from windows cmd to see any problem. If running a normal command window, I get almost the same path except it's missing the scala path item. If I run the command line (Admin), then the echoed path matches the environment variables version. Under this admin setting, scala works fine.
There is no user path variable defined, it's only a system variable.
I've never seen this before. Why is there a difference between admin path and non-admin path? And how do I access the scala path item from the non-admin command line?
Thanks!
I just had the same problem, it was caused by the environment variables not being refreshed. A reboot would have solved it, however there is a way to refresh the environment variables without a reboot.
Open cmd prompt window
Input set PATH=C
close and restart cmd prompt window
input echo %PATH% to check
This worked for me in Windows 10.

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

Resources