Hi all,
I want to pass the parameter from file1.bat to file2.bat
echo set filename=%~n0 >> file2.bat
But when I do the above echo statement and writes to a file2.bat, the command is executed and giving the file name, but I need set filename=%~n0 in file2.bat and not the command output. Is there a way I can achieve this
Thanks,
Somaraju
How to pass command from one bat file to another bat file
Moderator: DosItHelp
Re: How to pass command from one bat file to another bat fil
Show us what is in file2.bat please.
There is not enough description to properly understand the issue.
There is not enough description to properly understand the issue.
Re: How to pass command from one bat file to another bat fil
file2.bat Contains
set filename=file1
But needs below command in file2.bat
set filename=%~n0
Thanks,
Somaraju
set filename=file1
But needs below command in file2.bat
set filename=%~n0
Thanks,
Somaraju
Re: How to pass command from one bat file to another bat fil
Here you go:
Also consider this to protect the variable from some poison characters.
Code: Select all
>file2.bat echo set filename=%%~n0
Also consider this to protect the variable from some poison characters.
Code: Select all
>file2.bat echo set "filename=%%~n0"
Re: How to pass command from one bat file to another bat fil
Thank you it worked