As in Python3, you can view open programs or processes like a tasklist on the command line, but so that I can read everything into a variable? I am writing a bot for a telegram that will send information about the computer.

2 answers 2

Found a solution:

 import subprocess print(*[line.split() for line in subprocess.check_output("tasklist").splitlines()]) 

Reads from tasklist , and displays information.

     from subprocess import Popen, PIPE print(*[line.decode('cp866', 'ignore') for line in Popen('tasklist', stdout=PIPE).stdout.readlines()]) 

    out:

     Имя образа PID Имя сессии № сеанса Память ========================= ======== ================ =========== ============ System Idle Process 0 Services 0 4 КБ System 4 Services 0 300 КБ smss.exe 336 Services 0 320 КБ csrss.exe 440 Services 0 4 412 КБ wininit.exe 524 Services 0 576 КБ ...