How to run a Windows command from any folder? - command-line

Some CLI commands work from only specific folders; I want to make them run globally, from anywhere.
I installed redis-cli.exe in the path c:/redis/redis-cli.exe.
Now when I open a cmd in c:/redis/ and run redis-cli ping, it works.
However, if I run it from some other folder, it throws an error saying
'redis-cli' is not recognized as an internal or external command, operable program or batch file.
In contrast, Chocolatey or npm runs from a cmd console opened in any folder.

Solution: Add the path to that exe in your environment variables.
So for c:/redis/redis-cli.exe, add the value c:/redis to PATH in your environment variables.

Related

Yarn install problem when project folder name has spaces (link is not recognized as an internal or external command, operable program or batch file)

When I run yarn install in VS Code I get errors because my project is in folder whose name contains spaces.
If I write a command in console manually I can make use of quotes to avoid such problem (like cd "folder path with spaces")
How can I run yarn install and other commands if my project folder contains spaces? Maybe I can set some global setting to automatically put quotes around path names?

Mongodb database tool commands wont take effect

I want to use commands such as mongodump/mongorestore/mongoexport on my local windows computer and have therefor downloaded the .msi extension version of mongodb database tool and also executed the .msi so it could be installed.
But what do i do now to start using the commands. I cant find any documentaions of this. Is there something i have to configue?
When i execute a command like mongodump on my system command line i get the response:
'mongodump' is not recognized as an internal or external command, operable program or batch file.
Do i maybe have to execute the command from a certain dir location?
Look for the highlighted folder on your system. When you install the database tools this folder is created. Inside this folder there is a bin folder which contains all the commands you are looking for.
Once you find this folder then navigate to bin folder. And open a command prompt at that location. And try running the commands.
Alternatively:-
You can set PATH to bin folder and then you will be able to run the commands from anywhere.

Npm command not recognized (ubuntu)

After installing java 8 openjdk and exporting the variable via export I ran the following command:
source /etc/enviorment
I after that when I try to run npm run tests-e2e, it says the command is not recognized.
Executing source /etc/environment has reset your shell's environment variables back to their default values, throwing away any customisations that were applied by your shell's startup scripts (/etc/profile, ~/.bash_profile and so on). In particular, it looks like you've lost the customised value of $PATH that carried the path to the directory where the npm command lives.
To recover, you can do any of:
execute exec bash -l to get a new shell that will execute the
startup scripts and therefore rebuild a properly customised $PATH variable
if you're using the GUI, close the terminal window and open a new one
log out and then log back in

Command Prompt on Windows 8 not recognizing any commands

Here's a screenshot of the command prompt message:
It says "'$' is not recognized as an internal or external command, operable program or batch file."
I looked up how to fix it, then changed the PATH in computer properties and updated my Java like they said, but it's still not fixed.
Is gem the name of a program you're trying to run? Because you can just type gem install jekyll without the $. The gem executable would have to be in a folder that's present in the PATH variable.

Batch file in eclipse path variables not found

I want to start a batch-script in my eclipse. (Instructions here: How to run a batch script (.bat file) from eclipse)
In my batch file i need some commands like pear or phing.
I put the path to these commands into my environment variable called PATH.
(Works fine with cmd manually)
After starting the script, I'm getting this error:
'pear' is not recognized as an internal or external command,
operable program or batch file.
If I type pear by hand, it doesn't work either.
You need to restart Eclipse after changing the system environment; environment variable changes requires any process that is already running to be restarted in order for that application to pick up the changes.
Another option might be to put the full path to those commands in the .bat file so that it doesn't rely on the system environment in order to work properly.
Tip: Make sure to close and start eclipse afresh for PATH variable changes to take effect. Using the Restart option in File menu may not help here.