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.
June 17, 2008
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:
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.
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.
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:
C:Windowssystem32;C:Windows;C:Windowssystem32wbem
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:
C:Windowssystem32;C:Windows;C:WindowsSystem32wbem;C:bin
Now PowerShell can find the custom binaries and scripts you save to that folder.
About the Author
You May Also Like