The PATH environment variable

When you issue a command, the interface must know the location of the file or program to which the command refers. Like the example in the article Delimiters, spaces, and special characters, which runs example.zip, the path must be included (C:\Program Files\WinZip\example.zip). If you only type example.zip on your command line and then press Enter the result will be much the same as asking someone to hand you an item without first telling that person that the item is in another room.

If you will be issuing more than one command to the same location during a session, you can make things easier by editing your computer's PATH variable. This can be done temporarily or permanently. The examples below assume that multiple commands are going to be issued to the WinZip add-on which is found in the WinZip folder.

To temporarily change the PATH variable in a Command Prompt session so that it includes the WinZip folder, type:

PATH=%PATH%;C:\Program Files\WinZip

and press Enter (double quotes are not necessary as PATH does not use spaces as a delimiter). Once you have done this, you can type a command line that begins with either WZZIP or WZUNZIP during this Command Prompt session. If you do not have the path to the WinZip folder in your PATH variable, you must always include that path in your command, as in the example below.

"C:\Program Files\WinZip\WZZIP"

Note: The entire command above must be surrounded by double quotes due to the space in Program Files.

To permanently include the WinZip folder in the path, you would need to edit the Path Environment Variable. To do this:

  1. Open System from the Control Panel
    (change the Control Panel from the Category view to easily find this)
  2. Click the link for Advanced system settings on the left side of System
  3. In the Advanced tab of System Properties, click Environment Variables
    Advanced tab of System Properties
  4. In the System variables section, scroll to and select Path and then click Edit
    Environment Variables dialog
  5. Windows 10:
    In the Edit environment variable dialog, click New
    Edit environment variable dialog
  6. Type the full path to the WinZip folder (usually C:\Program Files\WinZip)
  7. Click OK in each open dialog and close System

If you have Windows 8, Windows 7, or Windows Vista, substitute these steps starting at number 5 above:

  1. In the Variable value text box, place your cursor at the end of the current value
  2. Type a semicolon as a delimiter
  3. Type the full path to the WinZip folder (usually C:\Program Files\WinZip)
  4. Click OK in each open dialog and close System

The next time you open the Command Prompt or run a script, you will no longer need to enter the Path to the WinZip folder for any commands using the add-on.

See also: Command Line Basics articles