-2

So I have a batch file. I want to add the batch commands from the batch file to my main python file. How can I do that? Is there a pip module for that?

Here's the batch code I want to add to the main python file:

@ECHO OFF
title TOG6 Spoofs


SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION

:menuLOOP

echo.--------------
echo.- TOG6 Spoofs -
echo.--------------
echo.
for /f "tokens=1,2,* delims=_ " %%A in ('"findstr /b /c:":menu_" "%~f0""') do echo.  %%B  %%C
set choice=
echo.&set /p choice= Please select your choice:  ||GOTO:EOF
echo.&call:menu_%choice%


::-----------------------------------------------------------
:: menu functions follow below here
::-----------------------------------------------------------

:menu_1   Spoof HDD Serial

SET CurrentDir=%~dp0
echo.Mapping Driver.
%CurrentDir%mapper.exe spoofer.sys
echo.Driver Mapped. HDD serial has been successfully changed.
pause
cls

Thanks! :-)

  • This site is not a free software programming or implementation service! Please take the [tour], visit the [help] and learn [ask] here! – aschipfl Jul 08 '20 at 14:59

1 Answers1

0

I think this post will help you but in short you'd do something like this:

from subprocess import Popen
p = Popen("batch.bat", cwd=r"C:\Path\to\batchfolder")
stdout, stderr = p.communicate()

If you wanted to get output from the batch file you can get that in the stdout.

GLaw1300
  • 195
  • 9