New
#1
Executing command line command anywhere ?
I want to create a setup whereas a command line command can be run from any directory/folder, without having to be in the directory/folder whereas the command line command resides ?
I want to create a setup whereas a command line command can be run from any directory/folder, without having to be in the directory/folder whereas the command line command resides ?
Add the directory the cmd or bat files resides in to the PATH environment variable.
To check or modify the system PATH environment variable, do the following:
XP: Right clock on My Computer
Vista, 7: Right click on Computer
Windows 8, 10: Right click on This PC
Select Properties
Vista, 7, 8, 10: Click on Advanced System Properties on the left
On the Advanced tab, click on Environment Variables
Under System Variables, scroll down to Path
Select it then click Edit
An easy way to look at all of it is to right click on the highlighted Variable Value field and select copy, then start Notepad and paste the data into there. That way you can easily look at all of it.
It's also a lot easier to make changes in Notepad then copy and paste the changed data back into the Path Variable Value field.
Click Ok as needed to exit when done
Two more alternative ways without tweaking system-wide settings.
Use push/popd to temporarily change current directory and run it from there (with the examples taking starting excel 2010 as my test piggy):
Or specifiy the full path in the call:Code:pushd "c:\program files\microsoft office\office14" excel popd
Code:"c:\program files\microsoft office\office14\excel.exe"
Interesting Alejandor, I assume if you restart your computer you have to use the Push command again to store the directory, little easier to store it as a system wide setting, this way, you can run the command in any directory :)