Page 1 of 1

How does TextPad "find" cmd.exe and/or command.com

Posted: Wed Jun 09, 2004 3:47 pm
by cxhamilton
I found a poll that asks how important is the ability to configure the command processor that TextPad uses to execute user (or built-in) tools, but I did not see an explanation on how TextPad goes about executing cmd.exe/command.com.

Does it:

1. Determine the OS and launch the command, assuming that it exists in a PATH directory?

2. Determine the OS and launch the full path to the command based on the known location?

3. Use an environment variable? (I believe that I have ruled this one out, but thought I would mention it anyhoo)

4. Black magic!?! :twisted:

I am asking, because I would very much like to use 4NT as the command processor for a couple of VSS-related tools that I have defined. The rub is that the Microsoft command processor does not support UNC paths as current directories.

I could write a batch file or Perl script that accepts $FileDir as an argument and changes the directory within the context of the script. I could even map the UNC paths to network drives ... but that does not answer my question, does it?

Thanks!
-Chris

Posted: Thu Jun 10, 2004 8:14 am
by ben_josephs
Why not specify 4nt as the program to be executed?

I use the following tool often. It opens a 4nt session starting in the directory of the current document:
Command: c:\4nt\4nt.exe
Parameters:
Initial folder: $FileDir

[x] Close DOS window on exit

Posted: Thu Jun 10, 2004 10:54 am
by cxhamilton
I have tried that with unsatisfactory results. Regardless of which command you "define" in the Tools menu, TextPad creates a temporary batch file, in $FileDir that contains the command you ultimately want to execute, its parameters, etc. The batch file is always executed by cmd.exe/command.com. Which does not support UNC paths.

Posted: Thu Jun 10, 2004 11:12 am
by ben_josephs
Exactly how are you specifying your tool? Nothing like that happens here.

Posted: Thu Jun 10, 2004 4:44 pm
by cxhamilton
It appears that I was partially mistaken in that TextPad does not always create a batch file. If "Close DOS window on exit" option is NOT checked, TextPad will create a batch file that uses the PAUSE command to keep the Tool from finishing.

So, I've gotten TextPad to execute 4NT directly ... which solves part of the problem. Now I have to figure out how to get the current project in VSS changed to $FileDir before the VSS checkout command is executed.

P.S. I'd still like to know how TextPad "finds" cmd.exe/command.com.

Thanks for your responses Ben!

Posted: Fri Jun 11, 2004 2:03 pm
by bveldkamp
cxhamilton wrote:
P.S. I'd still like to know how TextPad "finds" cmd.exe/command.com.
Most programs I know of use the %COMSPEC% environment variable to find the correct command processor.

Posted: Fri Jun 11, 2004 3:04 pm
by cxhamilton
TextPad does not use %ComSpec%

Posted: Fri Jun 11, 2004 3:18 pm
by bveldkamp
How do you know that?

Maybe TP has some sort of backup mechanism, if COMSPEC doesn't exist or points to a non existing file, try to find cmd.exe or command.com in %WINDIR% (or in %PATH%, whatever).

Posted: Fri Jun 11, 2004 3:28 pm
by cxhamilton
bveldkamp wrote:How do you know that?
I've modified %ComSpec% on both the system and user-level and cmd.exe is still being launched.

Posted: Fri Jun 11, 2004 4:01 pm
by bveldkamp
Just checking, did you restart TP after you modified comspec?

Posted: Fri Jun 11, 2004 4:44 pm
by cxhamilton
Yup!

Posted: Mon Jun 14, 2004 12:39 pm
by bveldkamp
OK, I guess you're right then and TP doesn't use COMSPEC. I have no idea why they wouldn't do that, though.

Posted: Sat Jun 19, 2004 7:39 pm
by bbadmin
If the COMSPEC environment variable is defined when a new DOS tool is added, then whatever it references is used, otherwise TextPad uses CMD.EXE on NT/Win2K/XP and COMMAND.COM on Win9X/ME.

Keith MacDonald
Helios Software Solutions