S
S
Stan2018-03-12 12:57:06
Python
Stan, 2018-03-12 12:57:06

How to get the output of the executed command?

subprocess.Popen([r'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'] + [r'Get-WMIObject -Class Win32_ComputerSystem -Computer "PC000329"|Select-Object Username'])
how to intercept the data that came to the console turned over.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sly_tom_cat ., 2018-03-12
@SantaKlaud

from subprocess import check_output

out = check_output([r'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe'] + [r'Get-WMIObject -Class Win32_ComputerSystem -Computer "PC000329"|Select-Object Username'])

K
Konstantin Nagibovich, 2018-03-12
@nki

Google for once

https://lexichdev.wordpress.com/2014/02/06/capturi...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question