[Release] Kai Liu's Open Command Prompt Addon v1.0.3-070925

Discuss & post Update Pack addons here.
Post Reply
User avatar
Mrs Peel
The Dominatrix Recoded
Posts: 1344
Joined: Tue Jan 17, 2006 2:02 am
Location: Aotearoa
Contact:

[Release] Kai Liu's Open Command Prompt Addon v1.0.3-070925

Post by Mrs Peel » Sun Sep 23, 2007 8:10 am

Uh-oh, where did Neer Roggel's BackgroundCMD ShellExt go to? :P

LOL I dumped it tonight and replaced it with this much much better shell extension instead, thanks to a discovery by Code65536. But sadly for me (as with BackgroundCMD) I discovered that this also will not work in Xplorer2 (which I use as a my replacement file browser).

Be advised that some of you might not like what I have done with this installer, but I'll explain why I did it this way. I noticed that the native uninstaller for this does NOT give you a prompt to ask if you want to remove it, which really bugged me because it also runs silently so if you accidentally uninstalled it there is nothing to indicate this until the next time you go to open a CMD prompt with it.

So what I have done is to use some postsetup scripting to DELETE the programs native uninstall reg section (which it automatically generates when the shell dll file is registered) and replaced it with my own custom uninstall section which does have the uninstall prompt. And another nifty thing I notice is that my one does not add a PendingFileRenameOperation which requires a reboot to complete uninstallation - it just automagically removes the dll from shellext directory.

Anyhoo, I think those of you who use native windoze explorer as your file browser will really appreciate this one, so here yagoo peeps.... the BackgroundCMD addon that the addon fairy godmother transformed into Kai Liu's Open Command Prompt at midnite.... AND this one's open source too! YAY!!! :D

Open Command Prompt v1.0.3
LINK: MrsP_Open_CMD_Prompt_Addon_v1.0.3-070925
MD5: 94F011C0C6E7D8CD0B03E562FE4AC423
SIZE: 43 KB
Description: Open command prompt from shell in any directory
Op System: Windows 2000, XP & 2003 (x86 only)
Builddate: 2007/08/09
Language: English
Title: Open Command Prompt
Version: 1.0.3
License: Open Source
Website: http://www.ktechcomputing.com/cmdopen/
Installs to: "%system32%\shellext"
Uninstaller: Removes shell menu, dll and reg entries
What is the Open Command Prompt Shell Extension?
The Open Command Prompt Shell Extension adds an "Open Command Prompt" menu item to the context menus (right-click menus) in Windows Explorer so that you can open a command prompt in the selected directory (or directories) or in the current directory that you are viewing. The Open Command Prompt Shell Extension is very lightweight (only 16 KiB installed!), supports network paths, is available in multiple languages, and is open-source.

How is this different from Microsoft's Open Command Window Here PowerToy?
The Open Command Prompt Shell Extension was created primarily to address the shortcomings of the Open Command Window Here PowerToy. If you already have the Open Command Window Here PowerToy installed, you should uninstall it before installing the Open Command Prompt Shell Extension. Improvements include:
1. The ability to open a command prompt in the directory that you are currently in by right-clicking on any empty screen space in the directory. This eliminates the need to navigate up a level in order to open a command prompt in the current directory.
2. Support for opening command prompts with UNC paths (directories on network shares).
3. Support for multiple languages.

How is this different from BackgroundCMD?
The Open Command Prompt Shell Extension offers these improvements over BackgroundCMD:
1. All-in-one functionality: BackgroundCMD only opens command prompts for the current directory, so in order to open a command prompt for a subdirectory, it had to be combined the Open Command Window Here PowerToy.
2. Support for Unicode paths.
3. Much smaller size: The final installed size is only 16 KiB, and this was achieved without any PE packing!
Image

May the source be with you!

:D

PS: On second thoughts, I decided to leave Neer's one available as well, but I shan't be maintaining it anymore OK ;)
BackgroundCMD v1.0.0.2
LINK: MrsP_BackgroundCMD_ShellExt_Addon_v1.0.0.2-070923
MD5: E7358E467CD4F392D8A18DFD16AFA49D


[Edit 2007/09/25] Replaced Neer Roggel's BackgroundCMD Shell dll with Kai Liu's Open Command Prompt and added some custom postsetup tweaks
Last edited by Mrs Peel on Mon Oct 08, 2007 1:02 am, edited 1 time in total.

User avatar
Mrs Peel
The Dominatrix Recoded
Posts: 1344
Joined: Tue Jan 17, 2006 2:02 am
Location: Aotearoa
Contact:

Post by Mrs Peel » Tue Sep 25, 2007 8:51 am

Updated package with an infinitely better CMD prompt shell DLL....

dkrus
Posts: 372
Joined: Wed Jun 21, 2006 1:54 pm

Post by dkrus » Tue Sep 25, 2007 9:08 am

Thanks Mrs Peel

User avatar
n7Epsilon
Moderator
Posts: 624
Joined: Thu Feb 17, 2005 1:37 am
Location: Cairo, Egypt

Post by n7Epsilon » Tue Sep 25, 2007 9:10 am

Thanks a lot for this addon Mrs Peel.
I can't live without this and I have always wanted a true addon for it (I don't like switchless installers for anything simple that can be done with INF or less than a few MBs)...

Anyhow here are some suggestions to make this addon better :-):
1. Rename the external Inf to something that doesn't change (eg: CmdOpen.inf) so that in future releases one can integrate over the old one without breaking their source.
2. A good way to check if the dll can be used with RegisterDLLs is to use NirSoft's "DLL Export Viewer" and open the DLL with it. If you see DllRegisterServer in the list of exported functions, then you can use RegisterDLLs directive instead of adding the registry entries yourself... :-)
3. It would be cleaner if you could put the DLL inside a cab file, it can help for example if one wants to reinstall it if it gets corrupted for some reason, one can just go to %WinDir%\INF and just right-click > Install to force the file to be copied again...

Thanks again for your great contributions (I may have a surprise for addon makers in the near future)...

User avatar
ENU_user
Posts: 1253
Joined: Wed Jan 25, 2006 1:42 pm

Post by ENU_user » Tue Sep 25, 2007 9:48 am

well obviously the idea is pulled from BackgroundCMD so i cant see the point of having this old feature back since i personally hate it.
but options is always a good thing to have .

i stick to BackgroundCMD clean and simple & i hope neer keeps it that way ;)

1 useless item on -folder's-right click- drop down menu "now" ;)

User avatar
code65536
Posts: 735
Joined: Wed Mar 14, 2007 2:58 pm
Location: .us
Contact:

Post by code65536 » Tue Sep 25, 2007 6:24 pm

You can still use self-registration/unregistration instead of manually adding/deleting entries. The trick here is in an oft-forgotten (and oft-unimplemented) method of registration.

You see, if you pass the rarely-used "/i /n" switches to regsvr32, then that will cause regsvr32 to call DllInstall instead of DllRegisterServer (note that the official installation INF for the shell extension passes the 2 flag in the registration section instead of the usual 1 flag, which is effectively the same as using "/i /n" in regsvr32). DllInstall, not surprisingly, tries to do an install: so it will call up DllRegisterServer to register the DLL and then it'll do some other stuff, like add the uninstallation entries. But if all you want is to register the DLL and not do the other install stuff, then all you have to do is call up DllRegisterServer instead of DllInstall.

Anyway, this means that you are presented with lots of options with respect to how to install and uninstall. If you register the extension the old-fashioned way, like "regsvr32 CmdOpen.dll" without the "/i /n" flags, or if you pass the 1 flag instead of the 2 flag in the INF, DllRegisterServer will be called instead of DllInstall. This will only do the COM registration and won't create any uninstall registry entries (it also won't add the optional HKLM registry entry to allow command prompts to be opened on network shares), which gives custom installers more flexibility in how to carry out the install.

Similarly, you don't have to use the built-in uninstaller, either. Right now, the official uninstaller uses the "/i /n /u" regsvr32 flags, which calls DllInstall with an uninstall flag. And DllInstall then deletes the COM registration using DllUnregisterServer, deletes the uninstallation registry entries, and finally schedules the DLL for deletion at reboot. If you get rid of the "/i /n" flags and pass only the "/u" flag (or if this was an INF, then you'd use the 1 registration flag instead of the 2 registration flag), then you will instead call up DllUnregisterServer, which will only delete the COM registration and leave you to do the rest of the uninstall as you see fit.

So basically, by specifying/omitting "/i /n" (or using 1 or 2 as the INF registration flag), you can control how much you want the extension to do: either do everything, or just the minimum COM registration/unregistration. ;)

PS: Microsoft's dependency walker (bundled with Visual Studios but is also included in the XP support tools and PSDK tools and is also available here) will also show a list of exported functions (as well as DLL depedencies, which is pretty useful in determining if certain things require certain runtimes). You will see from DW or other DLL-export listers that CmdOpen.dll exports DllRegisterServer (for basic COM registration), DllUnregisterServer (for basic COM unregistration), and DllInstall (for self-install/uninstall). Or you could just peek at the source. ;)
Last edited by code65536 on Tue Sep 25, 2007 10:11 pm, edited 1 time in total.
My addons: CmdOpen - HashCheck - Notepad2 - MS Runtimes - DirectX

Into the breach, meatbags!

User avatar
code65536
Posts: 735
Joined: Wed Mar 14, 2007 2:58 pm
Location: .us
Contact:

Post by code65536 » Tue Sep 25, 2007 6:36 pm

ENU_user wrote:well obviously the idea is pulled from BackgroundCMD so i cant see the point of having this old feature back since i personally hate it.
but options is always a good thing to have .

i stick to BackgroundCMD clean and simple & i hope neer keeps it that way ;)

1 useless item on -folder's-right click- drop down menu "now" ;)
If you want CmdOpen.dll to handle only background opens, you can do that. All you have to do is delete these keys (or not install them in the first place):

Right-click for My Documents
SOFTWARE\Classes\CLSID\{450D8FBA-AD25-11D0-98A8-0800361B1103}\ShellEx\ContextMenuHandlers\CmdOpen Shell Extension

Right-click for drives
SOFTWARE\Classes\Directory\ShellEx\ContextMenuHandlers\CmdOpen Shell Extension

Right-click for directories
SOFTWARE\Classes\Drive\ShellEx\ContextMenuHandlers\CmdOpen Shell Extension

Delete those keys, and CmdOpen.dll will behave just like BackgroundCMD.

And there are other minor reasons to change, too. BackgroundCMD isn't as efficient as CmdOpen.dll (it's not just the file size, but CmdOpen.dll is rather tightly written; of course, for something this tiny, it doesn't make that much of a difference), and BackgroundCMD uses ANSI instead of Unicode (aside from creating problems with foreign characters, Windows NT is natively Unicode, so ANSI is inefficient because it forces Windows to do ANSI->Unicode conversions in the background, not that this is in any way significant given today's computers, of course...), so if all you want is the background open thing, then CmdOpen.dll is still a better option once you delete those keys.
My addons: CmdOpen - HashCheck - Notepad2 - MS Runtimes - DirectX

Into the breach, meatbags!

User avatar
ENU_user
Posts: 1253
Joined: Wed Jan 25, 2006 1:42 pm

Post by ENU_user » Tue Sep 25, 2007 8:03 pm

something sounds misleading when reading the section of "How is this different from BackgroundCMD?" on the site
1. All-in-one functionality: BackgroundCMD only opens command prompts for the current directory, so in order to open a command prompt for a subdirectory, it had to be combined the Open Command Window Here PowerToy.
"why this had to be combined"
for someone who doesn't know what is BackgroundCMD.
this sentence has a strange effect even for someone who "knows" but prefers not to. have any combination ;) ,fairly.

thats where i probably missed the rest

2. Support for Unicode paths.
3. Much smaller size: .etc

anyways its good you have aired up the topic with all the good info ,and especially the install method's for the shell.ext.dll its sounds simple and useful. and i agree if this can after all be adjusted to suit one needs ,especially if this offers more extended support and better code.

so thanks again for checking this all out ,will need to customize, and try.

cheers

User avatar
code65536
Posts: 735
Joined: Wed Mar 14, 2007 2:58 pm
Location: .us
Contact:

Post by code65536 » Tue Sep 25, 2007 8:22 pm

ENU_user wrote:this sentence has a strange effect even for someone who "knows" but prefers not to. have any combination ;) ,fairly.
Well, I think most people use the two as a combination (perhaps not the PowerToy per se, but in combination with something else similar)... :)
anyways its good you have aired up the topic with all the good info ,and especially the install method's for the shell.ext.dll its sounds simple and useful. and i agree if this can after all be adjusted to suit one needs ,especially if this offers more extended support and better code.
Well, the install is, admittedly, not very well documented. The official INF does have this comment:

Code: Select all

; Note that the registration flag is set to 2; we are calling DllInstall instead
; of DllRegisterServer.
Since this is open-source, the source code itself can serve as a form of documentation (there is in-code documentation for people not familiar with C). And of course, since it's open-source, if there's anything you don't like about it, you can change it. ;)
My addons: CmdOpen - HashCheck - Notepad2 - MS Runtimes - DirectX

Into the breach, meatbags!

User avatar
Zacam
Moderator
Posts: 615
Joined: Tue Sep 13, 2005 7:46 pm
Location: Portland, OR

Post by Zacam » Tue Sep 25, 2007 10:03 pm

YEAH! "or in the current directory that you are viewing"!

Pardon me, I'm going to now go be very very ecstatic and gleeful over this, my one and only pet peeve about all other "Prompt Here" ideas.

Right after I download and add to my Permanent Integration list, that is. :-)

*now I just need to edit it so that it just says "CMD Prompt" because that's teh way I like it. :-) *

roweezy
Posts: 25
Joined: Sun Aug 27, 2006 5:58 pm

Post by roweezy » Tue Sep 25, 2007 10:22 pm

yay! instant cmd prompt now anywhere...thanx

User avatar
Zyx_Maiden
Posts: 128
Joined: Mon Mar 12, 2007 9:32 pm
Location: Québec, Canada

Post by Zyx_Maiden » Sun Oct 07, 2007 11:11 pm

Thank you so much for this addon Mrs Peel, it works great!
If you see dinosaurs, stop using drugs. But, if you don't use drugs, GET THE HELL OUT OF THERE!

Post Reply