I'm launching batch script from windows task scheduler using subprocess. But the problem here is that the subprocess is linked to the task scheduler command output but not to the output of "Task Scheduler opened bat CMD Window"
from subprocess import Popen as sopen, PIPE, CREATE_NEW_CONSOLE
cmd = f"start /b cmd /c schtasks.exe /run /TN \"taskasadmin\""
task_start = sopen(cmd, shell=True, creationflags=CREATE_NEW_CONSOLE, stdout=PIPE)
time.sleep(3)
For temporarily I'm logging the bat file to txt in Windows Task Scheduler and parsing the output by reading line by line from that txt file.
cmd /c start.bat > check.txt
I want to read the output of that other opened command prompt window without logging it using windows task scheduler. Is there anyway to do this by using the pid of that bat cmd window to get stdout?