Proposed revision to "Open Command Prompt"

Discuss development issues and submit patches here
Post Reply
LarryBrasfield
Posts: 3
Joined: Sat Dec 15, 2012 12:00 pm

Proposed revision to "Open Command Prompt"

Post by LarryBrasfield »

As a user of a few alternative command-line-interface shells, (all vastly preferable to cmd.exe), I am prepared to make it possible to open a shell of my choosing with a selected directory as its current one.
This seems like an obvious improvement, but seeing many patches rejected which purport to add seemingly-desirable features, I would like to see if this proposal would fly, perhaps with some adjustment.

This all relates to the action taken upon pressing the "Show Command Prompt" button.
1. If the environment variable named 'ComSpec' is not set, (which it normally is on a Windows system), cmd.exe is run wherever found on %PATH%.
2. If %ComSpec% is set, and names an executable, by extension association or a .exe, it is run using usual launch processing to expand arguments that may be present. Note that on a stock-setup system, (where the user has not messed with the value %ComSpec%), this will run cmd.exe from a system directory without parameters, just as appears to be the case in Explorer++ v1.3.4

I would probably revise the quick-tip on that button to read "Command-Line Shell here", but that is perhaps a little much for those who never run cmd.exe at all.

Thanks,
--
Larry Brasfield
David Erceg
Site Admin
Posts: 933
Joined: Sat Apr 18, 2009 1:46 am

Re: Proposed revision to "Open Command Prompt"

Post by David Erceg »

Hi Larry,

That sounds good. I had been thinking about implementing it myself actually, after I saw your previous post. If you do end up creating a patch, I think you can probably drop the first step and simply assume the environment variable always exists. I also wouldn't worry about checking whether it's an .exe or not.

Oh, and I share your feelings about cmd.exe! It's never really bothered me in the past (probably because I've rarely had to use it), but I've been done some command line work recently, and it's very limiting. Copying text, for example, seems harder than it should be.
LarryBrasfield
Posts: 3
Joined: Sat Dec 15, 2012 12:00 pm

Re: Proposed revision to "Open Command Prompt"

Post by LarryBrasfield »

Ok, here is the modified spec:

When "Show Command Prompt" button is pressed, the value of the Explorer++ process environment variable named 'ComSpec' will be fetched, here called %comspec. Then, action will be taken depending upon the value obtained, as follows:
1. If empty, (zero length string), no action will be taken. (not even a message box explaining why nothing happens)
2. Otherwise, the system ShellExecute function will be called with these parameters:
hwnd = NULL,
lpOperation => "open" (in TCHARs)
lpFile => <comspecCommand>
lpParameters = NULL or => <comspecTail>
lpDirectory => <selectedExplorer++DirectoryPath>
nShowCmd = SW_SHOWNORMAL
where
<comspecCommand> is the initial non-whitespace character sequence of %comspec if %comspec does not start with doublequote, else is the whole doublequoted sequence.
and
<comspecTail> is the remainder, if any, without leading whitespace, of %compec after passing over the <comspecCommand> portion. If this is empty, NULL is passed.
3. If the ShellExceute call fails, a minimal message box with at least the error code will be put up.

Adjustments may be made to ensure that the behavior appears unchanged for users having the stock setting of ComSpec.
Post Reply