python WMI:如何在主屏幕上查看正在运行的进程

时间:2017-08-09 07:39:49

标签: python wmi

我正在使用python wmi在远程计算机上运行我的脚本。该脚本打开浏览器并执行一些操作。我能够在没有任何错误的情况下在远程计算机上运行该进程,但是我无法在远程节点的屏幕上看到浏览器。有没有办法将进程带到远程计算机的主屏幕?这是我的代码

import wmi,time

SW_SHOWNORMAL = 1

c = wmi.WMI("192.168.1.5", user="domain\myuser", password="mypassword")
process_startup = c.Win32_ProcessStartup.new()
process_startup.ShowWindow = SW_SHOWNORMAL

process_id, result = c.Win32_Process.Create(CommandLine="C:/Users/myUser/my.bat ", ProcessStartupInformation=process_startup)

if result == 0:
    print "Process started successfully: %d" % process_id
else:
    raise RuntimeError, "Problem creating process: %d" % result

watcher = c.watch_for (notification_type="Deletion", wmi_class="Win32_Process", delay_secs=1, ProcessId=process_id)
watcher()
print "Sionara"

0 个答案:

没有答案