views:

273

answers:

6

Linux allows me to have a short system path by placing binaries in just a few locations. I don't have to edit the path because I just installed a new application, and I don't have to hunt for applications I want to run. How can I, with PowerShell as the program I use to launch programs from, accomplish the same thing on Windows (Vista)?

+1  A: 

You could always add a .cmd file as an alias.

altCognito
Rather than use .cmd as an alias, you can just use PowerShell's built-in aliasing mechanism:Set-Alias Fiddler 'C:\Program Files\Fiddler2\Fiddler.exe'
Keith Hill
+2  A: 

Vista has a symlinks now via mklink. Perhaps you could setup a "c:/bin" folder and generate symlinks to point back to the original binaries. That is assuming that Vista's symlinks work similarly to the ones in Linux. Here's a short tutorial.

dustyburwell
They do work similarly but you have another problem, then. Many programs assume their data or libraries to be in the directory they are installed in (as for libraries this is also an artifact of LoadLibrary). So by symlinking just the exe to another path you are starting C:\bin\blah.exe which thn fails to load any of its data/libraries because they're not in C:\bin but rather in %ProgramFiles%\Blah. So it's a rather brittle solution. Windows is, after all, an entirely different environment than Unix. Trying to have it both ways usually doesn't work out properly.
Joey
A: 

I install apps into c:\bin .

Cheeso
+2  A: 

Many programs create an app paths entry in the registry (HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths). For those apps, you can start them like so:

PS> Start-Process <appname>
PS> Start-Process excel

If you don't have PowerShell V2, which provides Start-Process, you can use the PowerShell Community Extensions on V1.

Keith Hill
+2  A: 

I kinda think I may be misunderstanding the question and this might be obvious but I hope it helps in case you didn't already know all this.

It sounds like adding a few directories to your path environmental variable might help. From the command prompt you can view all environmental variables with the set command. Then you can cut and paste your path and use set again to add to it. If you prefer the GUI route right click on My Computer -> Properties -> (in vista and 7 go to "Advanced System Settings" on the left in XP skip this step) -> Advanced Tab -> At the bottom there is an Environmental Variables button. When something is invoked form the command line windows checks in all the directories marked in the path first. After your app dir is in the path you can execute it without fully qualifying your path.

Hope that helped!

Copas
In Vista and Windows 7 you can get there even quicker by just searching for "environment" on the start menu, as there is an entry "Edit environment variables for your account"
Joey
A: 

Using specifically Powershell you can just create aliases for programs you want to start. I doubt that this is actually less work than editing the PATH environment variable, though.

Joey