国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

使用python的wmi進(jìn)行遠(yuǎn)程連接的時(shí)候報(bào)錯(cuò)

瀏覽:96日期:2022-07-27 08:55:43

問(wèn)題描述

# -*- coding: utf-8 -*-import wmi,jsonimport timeimport tracebackimport syslogfile = ’logs_%s.txt’ % time.strftime(’%Y-%m-%d_%H-%M-%S’, time.localtime())#遠(yuǎn)程執(zhí)行bat文件def call_remote_bat(ipaddress,username,password): try:#用wmi連接到遠(yuǎn)程服務(wù)器conn = wmi.WMI(computer=ipaddress, user=username, password=password)filename=r'C:123.bat' #此文件在遠(yuǎn)程服務(wù)器上cmd_callbat = 'start c:123.bat'conn.Win32_Process.Create(CommandLine=cmd_callbat) #執(zhí)行bat文件print '執(zhí)行成功!'return True except Exception,e:log = open(logfile, ’a’)log.write((’%s, call bat Failed!rn’) % ipaddress)log.close()print traceback.print_exc(file=sys.stdout)return False return Falseif __name__==’__main__’: call_remote_bat(ipaddress='192.168.110.131', username='Administrator', password='123456')

以上是遠(yuǎn)程連接的代碼,運(yùn)行和報(bào)錯(cuò)如下:

Traceback (most recent call last): File 'D:/untitled/???????.py', line 11, in call_remote_bat

conn = wmi.WMI(computer=ipaddress, user=username, password=password)

File 'C:Python27libsite-packageswmi.py', line 1290, in connect

handle_com_error ()

File 'C:Python27libsite-packageswmi.py', line 241, in handle_com_error

raise klass (com_error=err)

x_wmi: <x_wmi: Unexpected COM Error (-2147352567, ’xb7xa2xc9xfaxd2xe2xcdxe2xa1xa3’, (0, u’SWbemLocator’, u’RPC u670du52a1u5668u4e0du53efu7528u3002 ’, None, 0, -2147023174), None)>None

這是什么錯(cuò)誤,有哪位高手可以解答一下

這個(gè)報(bào)錯(cuò)我在主機(jī)ping通虛擬機(jī)(遠(yuǎn)程計(jì)算機(jī))之后,運(yùn)行代碼,還是以上的報(bào)錯(cuò),這又是什么情況呢?哪位高手幫忙解答一下,謝謝。

問(wèn)題解答

回答1:

看錯(cuò)誤提示是服務(wù)器不可用啊,你需要確保你遠(yuǎn)程的服務(wù)器可以ping通,另外用戶和密碼要對(duì)的上。

回答2:

b’xb7xa2xc9xfaxd2xe2xcdxe2xa1xa3’.decode(’gbk’)’發(fā)生意外。’u’RPC u670du52a1u5668u4e0du53efu7528u3002 ’’RPC 服務(wù)器不可用。 ’

標(biāo)簽: Python 編程
相關(guān)文章:
主站蜘蛛池模板: 明溪县| 景德镇市| 酒泉市| 平原县| 盐池县| 松阳县| 江油市| 许昌市| 吴江市| 栾城县| 东光县| 阜城县| 仁布县| 龙泉市| 蓝田县| 珲春市| 射洪县| 天水市| 新平| 金乡县| 罗甸县| 长岭县| 环江| 库尔勒市| 阿瓦提县| 河间市| 昌宁县| 阳朔县| 大石桥市| 濉溪县| 攀枝花市| 洪江市| 延庆县| 成都市| 满洲里市| 江油市| 那曲县| 习水县| 民勤县| 潼关县| 前郭尔|