python編程實(shí)現(xiàn)對(duì)遠(yuǎn)程執(zhí)行bat文件時(shí)遇到的錯(cuò)誤
問(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.110', username='Administrator',password='12345678')報(bào)錯(cuò)情況如下: C:Python27python.exe D:/untitled/遠(yuǎn)程連接.pyTraceback (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_access_denied: <x_wmi: Unexpected COM Error (-2147352567, ’xb7xa2xc9xfaxd2xe2xcdxe2xa1xa3’, (0, u’SWbemLocator’, u’u62d2u7eddu8bbfu95eeu3002 ’, None, 0, -2147024891), None)>None
這是什么錯(cuò)誤呢,有哪個(gè)高手幫忙解答一下,謝謝~
問(wèn)題解答
回答1:錯(cuò)誤提示得很清楚,拒絕訪問(wèn)
回答2:我說(shuō)說(shuō)看到的一個(gè)錯(cuò)
cmd_callbat = 'start c:123.bat'
回答3:print 'xb7xa2xc9xfaxd2xe2xcdxe2xa1xa3'發(fā)生意外。
一個(gè)個(gè)排除了,要么是連接意外, 先不執(zhí)行腳本,執(zhí)行一個(gè)最簡(jiǎn)單的cmd 命令,dir 之類(lèi)的,看看有沒(méi)有正確返回。然后,再執(zhí)行腳本,看看
相關(guān)文章:
1. javascript - vue2如何獲取v-model變量名2. javascript - 求幫助 , ATOM不顯示界面!!!!3. html5 - HTML代碼中的文字亂碼是怎么回事?4. javascript - vue2.0中,$refs對(duì)象為什么用駝峰的方式獲取不到屬性?5. python bottle跑起來(lái)以后,定時(shí)執(zhí)行的任務(wù)為什么每次都重復(fù)(多)執(zhí)行一次?6. 解決Android webview設(shè)置cookie和cookie丟失的問(wèn)題7. javascript - nodejs使用mongoose連接數(shù)據(jù)庫(kù),使用post提交表單在后臺(tái),后臺(tái)處理后調(diào)用res.redirect()跳轉(zhuǎn)界面無(wú)效?8. javascript - 能否讓vue-cli的express修改express重啟服務(wù)9. python - 爬蟲(chóng)模擬登錄后,爬取csdn后臺(tái)文章列表遇到的問(wèn)題10. html5 - 急求?被公司問(wèn)住了
