Modifying the Path to Executables
If you need to modify the known paths of the system, you can do so with either the SET PATH statement or via the GUI. As an example, you may have an executable in the C:\App path, and you may want this path included in the Path variable. You can use one of these methods.
SET PATH Command
Before modifying the path, take a look at what it currently is with the following command:
SET PATH
You can use the SET PATH statement to modify the path to include the C:\App folder with the following command.
SET PATH = C:\App
After you modify the path, view the current path by executing SET PATH again. You'll notice that there are two paths currently set-the original default path and another PATH = C:\App path that you just created, as shown in code Listing 1 and Listing 2. Listing 1 is what appears before executing the Set Path = C:\App statement. Listing 2 shows what appears after executing the statement.
Listing 1: Output of the Set Path statement
Path=C:\Windows\system32;C:\Windows; C:\Windows\System32\Wbem; c:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\; C:\Windows\System32\WindowsPowerShell\v1.0\; C:\Windows\System32\Windows System Resource Manager\bin; C:\Windows\idmu\common;C:\Program Files\Windows Imaging\ PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
Listing 2: Output of the Set Path statement after appending the path
Path=C:\Windows\system32;C:\Windows; C:\Windows\System32\Wbem; c:\Program Files (x86)\Microsoft SQL Server\90\Tools\binn\; C:\Windows\System32\WindowsPowerShell\v1.0\; C:\Windows\System32\Windows System Resource Manager\bin; C:\Windows\idmu\common;C:\Program Files\Windows Imaging\ PATH = C:\App PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
Note This behavior of the set path statement is different in Windows 7 than it was in previous versions of Windows In previous versions, if you used the Set Path = C:\App statement, it would overwrite the previous path and only C:\ App would be included in the path However, when you execute the Set Path statement in Windows 7, it appends, not replaces, the current path This modified path will be modified for only the current session. In other words, if you exit the command-prompt window, launch it again, and enter SET PATH, you'll see only the original system default path.
In this tutorial:
- Working with the Command Prompt
- Starting and Ending a Command Prompt Session
- Easy ways to invoke administrator Command Prompt sessions
- Starting Command Prompt at a Particular Folder
- Strings with Spaces Need Quotes
- Cmd.exe vs. Command.com
- Commands Are Not Case Sensitive
- Starting Command Prompt and Running a Command
- Cmd.exe and Other Command Prompts
- Using AutoRun to Execute Commands When Command Prompt Starts
- Using Cmds Command-Line Syntax
- Using Commands
- Type /? for help
- Starting Programs
- Open Windows Explorer at the current Command Prompt folder
- Using File-Name and Folder-Name Completion
- Use a different completion character
- Using Wildcards
- Editing the Command Line
- Using Command Symbols
- The Redirection Symbols
- The Pipe Symbol
- The Command Combination Symbols
- Pausing or Canceling Commands
- Simplifying Command Entry with Doskey Macros
- DOSKEY Saves Typing
- System Variables Identify the Environment
- Viewing Environment Variables
- Modifying Environment Variables
- Predefined Environment Variables
- Customizing Command Prompt Windows
- Setting the Window Size and Position
- Setting the Window Size and Position Visually
- Selecting a Font
- Setting Colors
- Setting Other Options
- Copy and paste in the command prompt window
- Navigating from the command prompt
- Printing a list of filenames
- Commands Use Paths
- Identifying Executables
- Modifying the Path to Executables
- Modifying the Path with the GUI
- Changing the Current Path with CD
- Changing the Current Path with Windows Explorer
- Capturing the Output
- A Sampling of Commands
- Dir
- Copy
- XCopy
- SET
- NET USE
- SystemInfo
- DriverQuery
- Echo
- Advanced Shell Commands
- Creating a Batch File
- Scheduling a Batch File
- Creating Scheduled Tasks with a Script
- Using Windows PowerShell and the PowerShell ISE
- Windows PowerShell ISE
- PowerShell Commands
- Verbs and Nouns
- Sending Output to a Text File
- PowerShell Syntax
- Variables Created with a $ Symbol
- Comparison Operators
- Parentheses, Brackets, and Braces
- Running PowerShell Scripts
- PowerShell Execution Policy
- Changing the Execution Policy
- Looping
- Collections
- Creating a PowerShell Script
- Documenting Scripts
- Using PowerShell Commands
- Getting Help on PowerShell
- Using WMI_Cmdlets
- Getting Details on an Object
- Querying Information on Specific Objects
- Terminate Applications with Win32_process
- Formatting Output with the -f Format Operator
- Filtering the Output with the Where-Object Command
- Using the IF statement
- Using the Switch Statement
- Script Reusability