如何通过在Python脚本中使用WMI连接提供Domian凭据来连接到远程计算机

时间:2017-02-21 06:35:30

标签: python-3.x

import wmi, time
ip = 'xx.xx.xx.xxx'
username = "XXXXXXX"
password = "XXXXXXX!"
SW_SHOWNORMAL = 1
from socket import *
print "Establishing connection to %s" %ip
c = wmi.WMI(ip, user=username, password=password)
process_startup = c.Win32_ProcessStartup.new()
process_startup.ShowWindow = SW_SHOWNORMAL
process_id, result = c.Win32_Process.Create
 (CommandLine="Notepad.exe",ProcessStartupInformation=process_startup)
if result == 0:
  print "Process started successfully: %d" % process_id
else:
  raise RuntimeError, "Problem creating process: %d" % result

请帮助:如何在域名

下连接域凭据

1 个答案:

答案 0 :(得分:0)

您必须指定“machinename”或“domainname”作为用户名的前缀。这是指定machnename的example作为用户名的前缀。域名也是如此。

HTH。