Adding a Folder to the Windows Command Search Path

Here's a basic procedure you can follow to add a custom folder to the Windows search path. Any scripts or binaries you want Windows to be able to find by name you can stick in that folder.

Alex Angelopoulos

June 17, 2008

2 Min Read
the word powershell on an abstract coding background
Alamy

To use the Windows PowerShell scripts discussed in "Use the .NET WebClient Class in PowerShell Scripts to Access Web Data," you need to run them from a location in the PowerShell command search path, which means a folder that PowerShell checks when you specify a command name that it can't identify as a known alias, cmdlet, or function. Here's a basic procedure you can follow to add a custom folder to the Windows search path. Any scripts or binaries you want Windows to be able to find by name you can stick in that folder. The steps are as follows:

  1. Create the folder. I usually name this folder bin and place it on the root of my system drive, so the folder path is C:bin.

  2. Before adding anything to the folder, set strict permissions on it. Only administrative users should have the power to modify anything in the folder. All users can have permission to read, execute, and list the contents.

  3. Add the folder to the Windows search path. On Windows Vista or later, select Systems and Maintenance in the Control Panel, then select System. In the System application, select Advanced system settings from the Tasks list on the left to bring up the System Properties dialog box. (On pre-Vista systems, select the System application in the Control Panel to bring up the System Properties dialog box.) On the Advanced tab of the System Properties dialog box, click the Environment Variables button to display user and system variables. In the System variables section, select the Path variable and click Edit. On a system that hasn't had the system path customized, you'll typically see something like this for the current path:

Related:Mastering Windows File System Navigation With PowerShell

 <span style="font-size: 10pt; line-height: 115%; font-family: 'Arial','sans-serif'">  <span style="color: black; text-decoration: none; text-underline: none">C:Windowssystem32;C:Windows;C:Windowssystem32wbem</span></span>

These are the folders that Windows automatically searches for external command files, separated by semicolons. Simply add another semicolon and the path to the folder you created. If it was C:bin and you already had the simple path just given, your system path should look like this when you're done: 

 <span style="font-size: 10pt; line-height: 115%; font-family: 'Arial','sans-serif'">  <span style="color: black; text-decoration: none; text-underline: none">C:Windowssystem32;C:Windows;C:WindowsSystem32wbem;C:bin</span></span> 

Now PowerShell can find the custom binaries and scripts you save to that folder.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like