python編程實現(xiàn)對遠(yuǎn)程執(zhí)行bat文件時遇到的錯誤
問題描述
代碼如下
# -*- 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')報錯情況如下: 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
這是什么錯誤呢,有哪個高手幫忙解答一下,謝謝~
問題解答
回答1:錯誤提示得很清楚,拒絕訪問
回答2:我說說看到的一個錯
cmd_callbat = 'start c:123.bat'
回答3:print 'xb7xa2xc9xfaxd2xe2xcdxe2xa1xa3'發(fā)生意外。
一個個排除了,要么是連接意外, 先不執(zhí)行腳本,執(zhí)行一個最簡單的cmd 命令,dir 之類的,看看有沒有正確返回。然后,再執(zhí)行腳本,看看
相關(guān)文章:
1. python - [已解決]flask QQ郵箱mail2. html - eclipse 標(biāo)簽錯誤3. 主題切換問題,用過別人的webapp在后臺切換模板主題后手機端打開網(wǎng)頁就是切換到的主題了4. javascript - 小程序中遇到j(luò)s執(zhí)行時序問題5. mysql 5個left關(guān)鍵 然后再用搜索條件 幾千條數(shù)據(jù)就會卡,如何解決呢6. 按照本節(jié)給的代碼“膽小如鼠”并不能變成紅色7. mysql - 在不允許改動數(shù)據(jù)表的情況下,如何優(yōu)化以varchar格式存儲的時間的比較?8. python3.x - git bash如何運行.bat文件?9. javascript - 為什么在谷歌控制臺 輸出1的時候,輸出的1立馬就不見了10. javascript - position fixed;設(shè)置了height 100 卻不是瀏覽器可視窗口的寬高,求大神釋疑。
