1.

Solve : How to find "Invoking file name" with batch file?

Answer»

Hi to All,

Can any body help find the name of file fire batch file.

I explain detail..

If "y.abc" call "x.bat",then in "x.bat" show y.abc is invoking me.
If "z.abc" calls "x.bat" then "x.bat" show "z.abc" is invoking me.

I'm sorry if my English is poor..

/thanks
satishIs there an actual need for this, or is this an academic question?

You can set a variable in the FIRST batch file
You can launch the SECOND batch file with a "%~f0" parameter

Thanks for quick reply foxidrive,

I modified my question..Please one check it.

Your answer is perfect when sending parameters when CALLING batch file.But I need to call .bat file with out sending any parameters.

Thanks
SatishUnless otherwise limited by setlocal/endlocal statements, NT variables live as long as the CMD session and are global in scope. Variables can be passed thru the environment bypassing the need for command line arguments:

A.bat
Code: [Select]@echo off
set theCaller=%~nx0
call b.bat
echo Good to be back home

B.bat
Code: [Select]@echo off
echo %~nx0 was invoked by: %theCaller%

a.bat puts its name into the environment where b.bat can retrieve it. Control then returns back to A.bat where the final message is displayed.

Good luck. Thanks all, i found working with registry is simple. So i follows COOKIE Butter comment in http://stackoverflow.com/questions/19962003/batch-file-invoked-file-details .

Thanks for help..



Discussion

No Comment Found