Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DOS Call cmd

Status
Not open for further replies.

DebiJo

Technical User
Apr 30, 2002
363
US
Is there anyway to capture the name of the .cmd file that initiated the call?

test1.cmd
call test2.cmd
exit

test2.cmd
echo ?????? (to give me "test1.cmd")

I need the echo (or whatever command) give me the name of the batch file that initiated the call from inside the called program. Is there anyway to do this? (I can't pass a variable.)

Thanks in advance,
Debi
 
I know you said you can't use variables but why don't you set an environment variable in test1.cmd then reference it in test2.cmd? You're not passing variables between batch files then.

EG:

Line in test1.cmd:

set batchfile=test1.cmd

Line in test2.cmd:

echo Batch file is %batchfile%



--------------------------------------
"Insert funny comment in here!"
--------------------------------------
 
There are many programs that call "test2". I do not know what they all are. This is on 224 servers. I can't change the calling programs. I can only change the program that is called.

Is there any way?

Thanks again!
Debi
 
This is probably NOT what you're looking for - but the name of the batch file is always %0.

Try it:

save this to a file called "test.cmd"
Code:
@echo off
echo %0
 
Good to know, but not what I am after.

I need to know, from inside the called program, the name of the program that kicked off the call. Not the name of the called program itself.

Thanks again,
Debi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top