stars
(c)

September 5, 2009

Enhanced Command Prompt Portable

(按此閱讀這文章的中文版)

Do you use a lot of command line tools in your USB flash drive?

Command-line utilities

So, as a system administrator, you probably have got a bunch of useful command line tools with you on the go. To use them, you first plug in your USB flash drive, start the command prompt on the target computer, navigate to your drive, then find out where your program is, 'cd' to it and finally start it. But you're always using them, and as the list of executables and subfolders grows, you start to wonder whether there's an easier way. Command Prompt Portable to the rescue!

Command Prompt Portable is another portable software from PortableApps.com. It gives us a command prompt we can customize the way we want; one of the most useful customization is setting PATH to whatever locations we need. We simply edit a batch file called commandprompt.bat inside "CommandPromptPortable\Data\Batch" and set PATH to e.g. "%~d0\C7PE\app\Cmd\Exe", ... where we put our executables. "%~d0" will become the root of the USB drive automatically. Then we can use our commands right after we've opened Command Prompt Portable, no matter at which PC! So, insteading of getting frustrated with target computer's command prompt, we can actually bring our own and have our settings on the go.

To go further, here's my enhanced Command Prompt Portable with PStart as a launcher.

Enhanced Command Prompt Portable, ECPP 1.0, PStart

(The screen shot shown is Chinese but the downloadable version is in English)

The executables (.exe .bat .cmd .vbs...) I put inside my "CommandPromptPortable\Exe" folder displays as file1.exe file2.bat... while folders display as [dir1], [dir2]... I like to group my executables as there're a lot of them. My script makes it such that as long as I remember the name of an executable inside any subfolder, I can type and run it without going into the sub-sub-subfolder. No more need to edit commandprompt.bat for each new folder. It achieves this by dynamically setting PATH to all subfolders that contain executables where command prompt is run each time.
An optional feature is that only folders with executables inside will be appended to PATH, meaning PATH will be shorter, consuming less memory, searching faster. However, the disadvantage is startup time being slower due to extra processing. To enable it, see "commandprompt.bat /?".
The following maps the relationship between folders and PATH. Note the green line especially, while there are many folders inside UnxUtils, only "bin" and "wbin" are appended to PATH. That's because only those 2 folders contain executables.

Location is handled by PATH now, but what if I don't remember the name of the executable? Then I would first need to see what's inside subfolders using Dirc or Listc command.
This is a sample output of what's inside [Microsoft] and [PnP] folders -- "listc Microsoft Pnp"

Alternatively, in Dir /w style using Dirc -- "dirc Microsoft Netcat
By default, only executables (defined as .exe .bat .cmd .vbs...) are shown.



Features Summary:
  • Display a welcome message when Command Prompt Portable is run, where it also shows a list of command line executables placed inside "CommandPromptPortable\Exe\" in the USB drive. Root executables are listed as file1.exe, file2.bat, ... folders are listed as [Folder1], [Folder2]...
  • PATH is automatically and dynamically updated on each run (to detect new executables)
  • No need to edit commandprompt.bat for each new folder
  • Only folders with executables is appended to PATH to save space (optional)
  • Groups command line executables into folders (to avoid bleeding)
  • Work with DirC.bat and ListC.bat to list executables in specified [folder(s)] to easily know the name of the executables that can be run, e.g. "listC linux windows" (or dirc) would show all executables inside [linux] and [windows] folders
  • Doesn't depend on a static location. Command Prompt Portable can be placed anywhere.
(Note: All scripts inside "Data\Batch\" are my work)

You can download my customized Command Prompt Portable here with a few free executables included and use for yourself.

* Download here | MD5: 3930227f85901741c7c20911a92dca3c

You may bookmark or share this article using the following:

Share/Bookmark

No comments :

Post a Comment

 
Related article thumbnails