Transfering information from one batch file to another

leeroyMarv

New Member
Is it possible to actually transfer a line from one batch file to another, for instance;
@echo off
echo abcdefghij
start C:\windows\file.bat
Is it possible to transfer that last line into another program so that this program runs the bat file when it is opened, so they could both open when i run the program. I already tried copy, but unfortunately that simply erased all the data that i had in the second .bat and replaced it with the first one. Is it possible that i could just insert a line of code? Any help would be apreciated.
 
Why can't you just have another line in the first batch file?
@echo off
echo abcdefghij
start C:\windows\file.bat
start C:\windows\file2.bat

I used to start up 6 apps doing similar to this.

Added later: I re-read your post and decided I haven't a clue what you are trying to do. There's too much "this" and "that". Could you please explain what you are trying to do, the big picture.

Starman*
 
Last edited:
I mean more like, i already have the first batch file, and when i make the second batch file, i want it to insert its line of code into the original bat file, so that it runs that one. As i said before i already tried using copy, but instead of inserting a line of comand it just copied the entire program and erased my original. Couldn't i append it to the end of the first program. I can do that with words using something such as:
echo abcd >> C:\file.bat
but when it type a command such as
C:\bat.bat >> C:\file.bat
I believe it should insert the command "C:\bat.bat" into 'file.bat' but instead it will just open C:\bat.bat and insert nothing, same with 'md.' It seems when i do a process, it does the process first instead of just inserting that process into the coding of the other .bat.
 
I was hoping your explanation would give an overview of what you are trying to do. I just don't get why you need to copy code from one batch file to the other.

"i already have the first batch file"
Is that the code in your first post? Is this also the batch file you call the original?

Don't use several descriptions for the same batch file, it's confusing. I'll call them original.bat and second.bat to end the confusion. If you respond, don't call them anything else. You also mention a "program" and I have no idea which file you are talking about. My best guess is you are talking about the original/first batch file. That would make three different names for the same thing.

"when i make the second batch file"
How is it made?

"i want it to insert its line of code into the original bat file, so that it runs that one"
Why do you need to insert code into the original file? Why can't you just run the original batch file from the second one (with or without call command)?

To run original.bat from the second.bat, second.bat file just needs a line:
call original (the call is optional)

Starman*
 
Back
Top