【问题标题】:How to get the remote machine command prompt output in python?如何在python中获取远程机器命令提示符输出?
【发布时间】:2019-04-26 06:37:44
【问题描述】:

我正在尝试连接 Windows 远程计算机并在命令提示符下执行 .exe。但是,无法捕获命令提示符输出

工作:它使用 WMI 连接的 Windows 远程计算机并通过 Win32_Process 执行 .exe 不工作:无法捕获在命令提示符下打印的 .exe 输出

import wmi, subprocess
import os, datetime, inspect, sys
import Trigger_Campaign_Sub as fn
from socket import *
...
...
connection = wmi.WMI(ip, user=username, password=password)
process_id, return_value = connection.Win32_Process.Create(CommandLine="cmd.exe /c " + execommand)


process_id, return_value = connection.Win32_Process.Create(CommandLine="cmd.exe /c " + execommand)

这个给出了执行的进程ID,但是我需要在命令提示符下打印输出日志。

【问题讨论】:

    标签: python wmi


    【解决方案1】:

    我会看看这个帖子: Run a command in a windows remote server and get back the console output in C# .NET

    似乎使用 psexec 运行,在正确的设置下返回两端的 shell 输出。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多