Skip to content
Archive of posts filed under the Windows category.

A Script to Find All Aliases for a Cmdlet

I’ve mentioned before that I love PowerShell, but I’m still trying to commit enough Cmdlets and aliases to memory that I can be immediately productive from a Powershell prompt without having to have a browser window open to the Powershell documentation on another monitor. Several of the Cmdlets may also be referenced through one or more aliases, and it’s rather cumbersome to discover what aliases are defined for a given Cmdlet.

I stumbled onto a bit of code that will find all aliases for a given Cmdlet which I put it into a script named Find-Alias. That will let me type the following:

PS C:\>Find-Alias Get-ChildItem

CommandType     Name                     Definition
-----------     ----                     ----------
Alias           dir                      Get-ChildItem
Alias           gci                      Get-ChildItem
Alias           ls                       Get-ChildItem

Here is the script code:

param(
    [Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true, ValueFromPipeLineByPropertyName=$true)]
    [string]$Command)

Process
{
  get-alias | where-object {$_.Definition -match $Command}
}
Share

Supporting the Ribbon and Menus

(I’ve posted a version of this article on Code Project.)

I’ve finally come back to Ripsaw, in a round-about way. I’ve started working on the client application again as a way to investigate the Windows Ribbon Framework. Originally, I had planned to create a Ribbon implementation for Windows 7 and later, and a menu-based implementation for earlier Windows versions, or for users that preferred a menu over the Ribbon.

Scratch Ribbon Project

After I played around with the API a while, I realized it would be fairly simple to support both the Ribbon and the traditional menu in one executable. In this article I’ll describe a sample app that I put together that shows how to accomplish support for both command-selection methods.

(Download the source code)
(Download the executable)
(Download the Visual C++ 2010 Redistributable)

Continue reading ‘Supporting the Ribbon and Menus’ »

Share

It’s Not a DOS Prompt!

I’ve been hearing this a lot lately (you know who you are), so rather than pull all of you aside privately and give this lecture, I thought I’d do it once, publicly. You’re not running a DOS prompt.

When you click on that shortcut that says, “Command Prompt” in Windows XP, or you run cmd.exe from the “Run” box, you’re not starting a “DOS prompt.” What you are starting is a command line interface, or just “command line” if you prefer. If you haven’t actually run COMMAND.COM, it’s not DOS!.

So, please, next time don’t tell me to run your favorite utility “at the DOS prompt.” Let DOS rest in peace.

The first person to call Powershell a DOS prompt will get the lecture in real time.

Share

An API is Forever

An API is an interface. Those of you that have worked with COM already know that once an interface is published, it can never, ever change. Ever. Not until the end of time. The reason is that some bit of code somewhere is going to be using that interface, and if you change it you’ve just broken that code. Of course, not changing an interface also means not deleting a portion of it.

Continue reading ‘An API is Forever’ »

Share