Batch file to create another batch file

Asked

Viewed 356 times

0

Is it possible for a batch file (EXEMPLO1.bat) to create another batch file (EXEMPLO2.bat) already programmed? Where I determine EXEMPLO2.bat programming within EXEMPLO1.bat.

1 answer

2


Yes, just put the controls after the echo and use the symbol > to specify the name of the file you want to create.

You can specify any extension, the content will always be written in plain text.

Using only one symbol > the command will overwrite the contents of the specified file then.

Using two symbols >> the command adds a line at the end of the specified file then. You should use this if you are saving more than one command in the same file.

This command below creates another file with the command to open the notepad:

@echo off
echo START NOTEPAD.EXE >> abre_notepad.bat
echo Arquivo criado.
pause > nul

Browser other questions tagged

You are not signed in. Login or sign up in order to post.