how to write a batch file code example
Example 1: how to make a batch file
echo off
title MyBatchFile
color 0
echo This is a batch file
echo.
echo Batch files are made on a Windows PC.
echo They run inside of Command Prompt
echo Copy this code. Next, paste it inside of Notepad.exe.
echo Finally, save it as a .bat or .cmd file, run it, and there you have it!
echo Do you see it now?{Y/N}
set /p answer
if %answer% == Y exit
if %answer% == N goto loop
:loop
cls
echo This is a batch file
echo.
echo Batch files are made on a Windows PC.
echo They run inside of Command Prompt
echo Copy this code. Next, paste it inside of Notepad.exe.
echo Finally, save it as a .bat or .cmd file, run it, and there you have it!
echo Do you see it now(again)?{Y/N}
set /p answer2
if %answer2% == Y exit
if %answer2% == N exit
pause
exit
Example 2: how to run bat file without effect main code
import subprocess
from subprocess import Popen
import time
from multiprocessing import Process,freeze_support
def run_batfile(name='world'):
subprocess.call(["launch_pg.bat"])
if __name__ == '__main__':
# freeze_support()
p = Process(target=run_batfile)
p.start()
# p.join()
count = 0
while True:
count+=1
print(count)
time.sleep(1)
Example 3: how do i write a batch file
You can use notepad(windows) or texteditor(mac) or other programs i personally prefer Atom
To make it work you have to save the file and name it something that ends on .bat