久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

使用python的wmi進行遠程連接的時候報錯

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

問題描述

# -*- coding: utf-8 -*-import wmi,jsonimport timeimport tracebackimport syslogfile = ’logs_%s.txt’ % time.strftime(’%Y-%m-%d_%H-%M-%S’, time.localtime())#遠程執行bat文件def call_remote_bat(ipaddress,username,password): try:#用wmi連接到遠程服務器conn = wmi.WMI(computer=ipaddress, user=username, password=password)filename=r'C:123.bat' #此文件在遠程服務器上cmd_callbat = 'start c:123.bat'conn.Win32_Process.Create(CommandLine=cmd_callbat) #執行bat文件print '執行成功!'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')

以上是遠程連接的代碼,運行和報錯如下:

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

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

這個報錯我在主機ping通虛擬機(遠程計算機)之后,運行代碼,還是以上的報錯,這又是什么情況呢?哪位高手幫忙解答一下,謝謝。

問題解答

回答1:

看錯誤提示是服務器不可用啊,你需要確保你遠程的服務器可以ping通,另外用戶和密碼要對的上。

回答2:

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

標簽: Python 編程
相關文章:
主站蜘蛛池模板: 略阳县| 高陵县| 塔河县| 蒙山县| 丹巴县| 晋中市| 拜泉县| 宝丰县| 胶州市| 武强县| 吴川市| 桐乡市| 巴南区| 兴安县| 林西县| 封开县| 定边县| 隆尧县| 吉安市| 蓬安县| 盐山县| 商河县| 罗江县| 冕宁县| 美姑县| 五指山市| 读书| 宣化县| 民和| 佛坪县| 盐源县| 会昌县| 金寨县| 名山县| 泰安市| 铁岭县| 喀什市| 杂多县| 日喀则市| 永城市| 黄山市|