Inkoking .bat from within a .bat -- fails. Why?

R

Richard

Hi All,

I'm trying to invoke a simple file, F:\Temp\C.bat from within
another file, F:\Temp\S.bat. It fails in two respects:

1. It complains "Specified COMMAND search directory bad"
2. It destroys the prompt setup and loses track of the working
directroy

Anybody got any ideas? Transcript follows.

Regards,
Richard

F:\>
F:\>cd temp

F:\Temp>type s.bat
::: F:\Temp\S.bat
%windir%\system32\command.com F:\Temp\C.bat
@echo Calling C
@echo Bacl from C

F:\Temp>type c.bat
@echo Reached C!!


F:\Temp>dir %windir%\system32\command.com
Volume in drive F is F12-24GB_NT
Volume Serial Number is B4A5-608B

Directory of F:\WINXPPRO\system32

07/30/2005 02:53 PM 50,620 command.com
1 File(s) 50,620 bytes
0 Dir(s) 13,090,250,752 bytes free

F:\Temp>s

F:\Temp>F:\WINXPPRO\system32\command.com F:\Temp\C.bat
Specified COMMAND search directory bad
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.

F>
 
R

Richard

Hi All,

I forgot to mention that I'm running WinXP/SP2 and it's up-to-date with
Microsoft Update.

Also, my apologies for misspelling "Invoke" in the subject line. I
hope that didn't put off too may people :)

Regards,
Richard
 
P

Pegasus \(MVP\)

Richard said:
Hi All,

I'm trying to invoke a simple file, F:\Temp\C.bat from within
another file, F:\Temp\S.bat. It fails in two respects:

1. It complains "Specified COMMAND search directory bad"
2. It destroys the prompt setup and loses track of the working
directroy

Anybody got any ideas? Transcript follows.

Regards,
Richard

F:\>
F:\>cd temp

F:\Temp>type s.bat
::: F:\Temp\S.bat
%windir%\system32\command.com F:\Temp\C.bat
@echo Calling C
@echo Bacl from C

F:\Temp>type c.bat
@echo Reached C!!


F:\Temp>dir %windir%\system32\command.com
Volume in drive F is F12-24GB_NT
Volume Serial Number is B4A5-608B

Directory of F:\WINXPPRO\system32

07/30/2005 02:53 PM 50,620 command.com
1 File(s) 50,620 bytes
0 Dir(s) 13,090,250,752 bytes free

F:\Temp>s

F:\Temp>F:\WINXPPRO\system32\command.com F:\Temp\C.bat
Specified COMMAND search directory bad
Microsoft(R) Windows DOS
(C)Copyright Microsoft Corp 1990-2001.

F>

There are two problems in your batch file:
1. The command processor under WinXP is cmd.exe, not
command.com. Command.com is a legacy command
processor used for 16-bit applications.
2. Your version of command.com may be corrupted.

While you ***can*** shell out to another batch file with
your method, the following syntax is far simpler:

call F:\Temp\C.bat
 
R

Richard

Hi Pegasus,

Your "wings" have you flying today! Great response!
... the command processor under WinXP is cmd.exe

I apparently misread something that suggested that Cmd.exe was to bring
up the command window. Maybe if I'd use it, it'd bring up a new
Command Window for an instant. Thanks to your tuteladge, I won't have
to try it.
Your version of command.com may be corrupted.

That's OK if it is. I don't intend to ever run 16-bit apps again.

I checked back with my legacy textbook, "Tricks of the MS-DOS Masters".
There's no mention of a "call" command, so it's apparently an
extension Microsoft added to the 32-bit version. I'm thankful for
that.

Best wishes,
Richard
 
P

Pegasus \(MVP\)

Thanks for the feedback. I suggest you throw out your
"Tricks of the MS-DOS Masters". It describes how to
maintain a pushbike - you now have a fairly powerful
motorbike whose many features are not listed in your
outdated text book. Here are some of them:
- Loops
- If-then-else statements
- String manipulation such as substrings or string substitution
- Arithmetic statements
- Prompt for user input
- Comparison operators (GTR, GEQ, EQU etc)
- Screen output capture

Try this line as an example:
@echo off
for /F "tokens=3" %%a in ('dir C:\ ^| find /i "bytes free"') do echo %%a
bytes free on drive C:

Utter gobbledigook for DOS, perfectly comprehensible
to Win2000/XP.
 
R

Richard

Hi Pegasus,
throw out your "Tricks of the MS-DOS Masters"

It's a deal. There's a lot of stuff about XP commands on the 'Net. I
haven't gone beyond Help in the Command Window. What one or two things
do you recommend on the 'Net or in print?

While I have your ear, consider one more question: Every Command
Window opens in %HOMEDRIVE%\.%HOMEPATH%. I'd like to change that from
time to time as I go from project to project. What's a cool way of
doing that? I guess I could poke around the Registry and possible
change those environment variables, but that doesn't sound that great,
even though I could create a couple of .reg files to set/restore those
values painlessly. Any idea?

Thanks again for your guidance.

Regards,
Richard
 
P

Pegasus \(MVP\)

No need to poke around in the registry - simply create
a "Command Prompt" shortcut with these details:

Target: cmd.exe /f:blush:n /k mode con lines=50
Start in: C:\ (or wherever)

The /f: switch gives you automatic command completion.
You can now type cd \pr and press Ctrl+F repeatedly
to get Windows to propose one matching folder after
another that starts with "pr". If you have a file
"2006 Budget.xls" then 2+^F will open it immediately!

The /k etc. switch increases the number of lines in the
current window to 50.

While there are tutorials about, I don't know any - I picked
up my skills from the Command Prompt (e.g. by typing
set /?) and by following discussions in some newsgroups.
 
R

Richard

Hi Pegasus,
Target: cmd.exe /f:blush:n /k mode con lines=50
Start in: C:\ (or wherever)

You've hit another homer :)

It took me a while to figure out how to do this. In the course of
implementing the original tool, I've hit open the idea of having one
"MyCmds" directory and populating it with shortcut to my many
applications, e.g. Hex XVI32 Editor, Oxygen XML Editor, Paint Shop Pro
Graphics Editor ... instead of having my Path clutter with separate
entries for each of them. I like that a lot. Should have started that
decades ago.

I also discovered M/S XP Command Shell Overview,
http://www.microsoft.com/resources/...docs/en-us/ntcmds_shelloverview.mspx?mfr=true
which is exactly what I should have read about five years ago, maybe
more .

I didn't use the -f switch in this instance because I've only got three
directories I care about creating and recreating for a particular
project. But I appreciate the technique.

BTW, just to persuade you that your support hasn't just furthered some
madman's quest, I want to mention that I've just started using some
new tools for application/website development: Ruby, Rails and MySQL.
Rails is the finest development system for run-of-the-mill business
apps I've encountered in my fifty years of programming, most of it as
a computer consultant (now retired). But Rails requires a particular
order of detailed steps, some of which one usually iterarates through,
that I felt it useful to document my path. But I didn't want to write
a document to record that; I wanted a set of .bat's and .sql's that I
could actually execute as well as read. This, of course, has delayed
my completion of a project for a small local business (I guess I might
be "unretiring" a little), but I think it's worth it.

I'm good to ago now. Thank you again for your wonderful insights.

Best wishes,
Richard
 
P

Pegasus \(MVP\)

Thanks for the feedback.

Richard said:
Hi Pegasus,


You've hit another homer :)

It took me a while to figure out how to do this. In the course of
implementing the original tool, I've hit open the idea of having one
"MyCmds" directory and populating it with shortcut to my many
applications, e.g. Hex XVI32 Editor, Oxygen XML Editor, Paint Shop Pro
Graphics Editor ... instead of having my Path clutter with separate
entries for each of them. I like that a lot. Should have started that
decades ago.

I also discovered M/S XP Command Shell Overview,
http://www.microsoft.com/resources/...docs/en-us/ntcmds_shelloverview.mspx?mfr=true
which is exactly what I should have read about five years ago, maybe
more .

I didn't use the -f switch in this instance because I've only got three
directories I care about creating and recreating for a particular
project. But I appreciate the technique.

BTW, just to persuade you that your support hasn't just furthered some
madman's quest, I want to mention that I've just started using some
new tools for application/website development: Ruby, Rails and MySQL.
Rails is the finest development system for run-of-the-mill business
apps I've encountered in my fifty years of programming, most of it as
a computer consultant (now retired). But Rails requires a particular
order of detailed steps, some of which one usually iterarates through,
that I felt it useful to document my path. But I didn't want to write
a document to record that; I wanted a set of .bat's and .sql's that I
could actually execute as well as read. This, of course, has delayed
my completion of a project for a small local business (I guess I might
be "unretiring" a little), but I think it's worth it.

I'm good to ago now. Thank you again for your wonderful insights.

Best wishes,
Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top