0

In my school Unix servers, I can run certain programs on the command line without going to the file where they are located. For example,

shell> java filename

would run the file with java. The home-computer I use has Windows on it, and I was wondering if I could do something similar on the command line. Right not, I have to go to the path location of the executable, and type in the name of the executable to run it.

C:\longpath> java filename

Is it possible to access java (or any other program for that matter) without going to its file location via the Windows command line?

1 Answer 1

2

You can add the path to your program to the path environment variable. Then you can access files in that directory from anywhere in command-prompts that you open after changing the variable.

  1. Press ⊞Win+R
  2. Type systempropertiesadvanced and click [OK]
  3. Click [Environment Variables]
  4. Modify the path variable (use the top half for just the current user; the bottom half for all users):
    • If the path variable exists:
      1. Select it and click [Edit]
      2. Press End to go to the end of the variable
      3. Press ; and type or paste the path
      4. Click [OK] to accept and close out open dialog boxes
    • If the path variable doesn’t already exist:
      1. Click [New]
      2. Enter Path for the name
      3. Enter the path for the value
      4. Click [OK] to accept and close out open dialog boxes

Caveats:

  • Delimit multiple paths with ; (e.g., c:\foo;c:\bar;c:\baz)
  • Be careful not to mess up any existing paths or you can cause Windows to malfunction
    • You can copy the existing path to a text-editor like Notepad and make your changes there before copying it back to the dialog when you are happy; this is advisable because the edit field in the dialog is small, so you cannot see the whole thing like you can in Notepad (especially if you enable word-wrap)
  • The changes only apply to new command-prompts, so you’ll have to close existing ones and open a new one
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .