Subscribe to Windows IT Pro

 

Get Newsletters

  • Get the Latest News
  • Product Updates
  • Helpful Tricks
  • Productivity Tips

Subscribe Now!

June 18, 2008 12:00 AM

Adding a Folder to the Windows Command Search Path

Windows IT Pro
InstantDoc ID #99070
Rating: (0)

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:
   C:\Windows\system32;C:\Windows;C:\Windows\system32\wbem

 

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:\Windows\system32;C:\Windows;C:\Windows\System32\wbem;C:\bin

 

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

 

Related Content:

ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

White Papers

Get your Windows 7 deployment off to the right start by implementing PC lockdown. A locked-down environment is easier and cheaper to support since users are less likely to make unnecessary changes to the core system configuration - read more here!

Essential Guides

Is your iSCSI "lossy"? The reality is that most off-the-shelf Ethernet hardware deployed for iSCSI can lose packets, resulting in slow performance or application downtime. Learn how to assess your current iSCSI infrastructure and engineer an advanced iSCSI SAN infrastructure.

Web Seminars

What's the best way to keep your network safe from malware? In this web seminar, security expert Greg Shields suggests an alternative method to the traditional blacklisting approach that is common with anti-virus and anti-malware solutions.

eLearning Series

We bring the experts direct to you to share their real-world perspective and expertise. During each event, three sessions stream in real time, so you can learn, ask questions, and get solutions.
Upcoming event: Getting the Most with Exchange 2010 with Paul Robichaux

Subscribe to Windows IT Pro!

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.