Executing command line command anywhere ?


  1. Posts : 925
    Windows 10 Pro
       #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 ?
      My Computer


  2. Posts : 6,285
    Windows 10 Pro X64
       #2

    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
      My Computer


  3. Posts : 925
    Windows 10 Pro
    Thread Starter
       #3

    Ahhh thanks :) I was thinking something along the line at the time was drawing blanks :)
      My Computer


  4. Posts : 2,467
    Windows 7 Ultimate x64
       #4

    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):

    Code:
    pushd "c:\program files\microsoft office\office14"
    excel
    popd
    Or specifiy the full path in the call:

    Code:
    "c:\program files\microsoft office\office14\excel.exe"
      My Computer


  5. Posts : 925
    Windows 10 Pro
    Thread Starter
       #5

    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 :)
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 13:02.
Find Us