关于wmi [英] About wmi

查看:68
本文介绍了关于wmi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想阻止某些进程运行。代码在

之后。我遇到了一些意想不到的麻烦。

Probelm1:这个程序无法终止scrcons.exe并且

FNPLicensingService.exe,这是系统进程。

问题2:过了一会儿,这个程序会因错误而中止

文件C:\Python25 \lib \ wmi.py,第397行,在__call__

handle_com_error(error_info)

文件C:\Python25 \ lib \ wmi.py",第190行,在handle_com_error中提升

x_wmi," \ n" .join(exception_string)

UnicodeDecodeError:''ascii ''编解码器无法解码位置上的字节0xb7

14:序数不在范围内(128)

------------- ---------------------------------------

code-- -------------------------------------------------- ------------------------------

# - * - 编码:utf-8 - * -

导入pythoncom

导入wmi

导入线程

导入时间

来自xml .dom.minidom import parse,parseString


class Info(threading.Thread):

def __i nit __(self):

threading.Thread .__ init __(self)

def run(self):

print''在另一个主题中。 ..''

pythoncom.CoInitialize()

dom1 = parse(''processTerminateList.xml'')

config_element = dom1.getElementsByTagName (processTerminateList)

[0]

servers = config_element.getElementsByTagName(" processName")

尝试:

c = wmi.WMI()

for c.Win32_Process()中的进程:

表示服务器中的服务器:

if process .name == getText(server.childNodes):

process.Terminate()

print process.name

process_watcher = c.Win32_Process。 watch_for(" creation")

而True:

new_process = process_watcher()

name = new_process.Caption

打印名称

服务器中的服务器:

如果name == getText(server.childNodes):

new_process.Terminate()

finall y:

pythoncom.CoUninitialize()

def getText(nodelist):

rc =""

节点列表中的节点:

如果node.nodeType == node.TEXT_NODE:

rc = rc + node.data

return rc

如果__name__ ==''__ main__''


Info()。start()

------ ------------------------------------------------ <无线电通信/>
processTerminateList.xml ----------------------------------------- ------------------------------

<?xml version =" 1.0" encoding =" utf-8"?>

< processTerminateList>

< processName> scrcons.exe< / processName>

< processName> TXPlatform.exe< / processName>

< processName> mdm.exe< / processName>

< processName> FNPLicensingService.exe< / processName>

< processName> notepad.exe< / processName>

< processName> uedit32.exe< / processName>

< / processTerminateList>

I want to prevent some process from running. The code is in the
following. I encounter some unexpected troubles.
Probelm1: This program cannot terminate "scrcons.exe" and
"FNPLicensingService.exe",which are system processes.
Problem2:After a while, this program will abort by error
File "C:\Python25\lib\wmi.py", line 397, in __call__
handle_com_error (error_info)
File "C:\Python25\lib\wmi.py", line 190, in handle_com_error raise
x_wmi, "\n".join (exception_string)
UnicodeDecodeError: ''ascii'' codec can''t decode byte 0xb7 in position
14: ordinal not in range(128)
----------------------------------------------------
code----------------------------------------------------------------------------------
# -*- coding:utf-8 -*-
import pythoncom
import wmi
import threading
import time
from xml.dom.minidom import parse, parseString

class Info (threading.Thread):
def __init__ (self):
threading.Thread.__init__ (self)
def run (self):
print ''In Another Thread...''
pythoncom.CoInitialize ()
dom1 = parse(''processTerminateList.xml'')
config_element = dom1.getElementsByTagName("processTerminateList")
[0]
servers = config_element.getElementsByTagName("processName")
try:
c = wmi.WMI ()
for process in c.Win32_Process ():
for server in servers:
if process.name == getText(server.childNodes):
process.Terminate()
print process.name
process_watcher = c.Win32_Process.watch_for("creation")
while True:
new_process = process_watcher()
name = new_process.Caption
print name
for server in servers:
if name == getText(server.childNodes):
new_process.Terminate()
finally:
pythoncom.CoUninitialize ()
def getText(nodelist):
rc = ""
for node in nodelist:
if node.nodeType == node.TEXT_NODE:
rc = rc + node.data
return rc

if __name__ == ''__main__'':
Info().start()
------------------------------------------------------
processTerminateList.xml-----------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<processTerminateList>
<processName>scrcons.exe</processName>
<processName>TXPlatform.exe</processName>
<processName>mdm.exe</processName>
<processName>FNPLicensingService.exe</processName>
<processName>notepad.exe</processName>
<processName>uedit32.exe</processName>
</processTerminateList>

推荐答案

patrol写道:
patrol wrote:

我想阻止某些进程运行。代码在

之后。我遇到了一些意想不到的麻烦。

Probelm1:这个程序无法终止scrcons.exe并且

FNPLicensingService.exe,这是系统进程。

问题2:过了一会儿,这个程序会因错误而中止

文件C:\Python25 \lib \ wmi.py,第397行,在__call__

handle_com_error(error_info)

文件C:\Python25 \ lib \ wmi.py",第190行,在handle_com_error中提升

x_wmi," \ n" .join(exception_string)

UnicodeDecodeError:''ascii ''编解码器无法解码位置的字节0xb7

14:序数不在范围内(128)


--------- -------------------------------------------

代码------------------------------------------------ ----------------------------------

# - * - 编码:utf- 8 - * -

导入pythoncom

导入wmi

导入线程

导入时间

from xml.dom.minidom import parse,parseString


class Info(threading.Thread):

def __init __(自我):

threading.Thread .__ init __(self)

def run(self):

print''在另一个线程......''

pythoncom.CoInitialize()

dom1 = parse(''processTerminateList.xml'')

config_element = dom1 .getElementsByTagName(" processTerminateList")

[0]

servers = config_element.getElementsByTagName(" processName")

try:

c = wmi.WMI()

for c.Win32_Process()中的进程:

服务器中的服务器:

if process.name == getText(server.childNodes):

process.Terminate()

print process.name

process_watcher = c。 Win32_Process.watch_for(" creation")

而True:

new_process = process_watcher()

name = new_process.Caption

打印名称

服务器中的服务器:

如果名称== g etText(server.childNodes):

new_process.Terminate()

最后:

pythoncom.CoUninitialize()

def getText(nodelist):

rc =""

节点列表中的节点:

if node.nodeType == node。 TEXT_NODE:

rc = rc + node.data

返回rc


if __name__ ==''__ main __'':

Info()。start()

---------------------------- --------------------------

processTerminateList.xml ------------- -------------------------------------------------- --------

<?xml version =" 1.0" encoding =" utf-8"?>

< processTerminateList>

< processName> scrcons.exe< / processName>

< processName> TXPlatform.exe< / processName>

< processName> mdm.exe< / processName>

< processName> FNPLicensingService.exe< / processName>

< processName> notepad.exe< / processName>

< processName> uedit32.exe< / processName>

< / processTerminateList>
I want to prevent some process from running. The code is in the
following. I encounter some unexpected troubles.
Probelm1: This program cannot terminate "scrcons.exe" and
"FNPLicensingService.exe",which are system processes.
Problem2:After a while, this program will abort by error
File "C:\Python25\lib\wmi.py", line 397, in __call__
handle_com_error (error_info)
File "C:\Python25\lib\wmi.py", line 190, in handle_com_error raise
x_wmi, "\n".join (exception_string)
UnicodeDecodeError: ''ascii'' codec can''t decode byte 0xb7 in position
14: ordinal not in range(128)
----------------------------------------------------
code----------------------------------------------------------------------------------
# -*- coding:utf-8 -*-
import pythoncom
import wmi
import threading
import time
from xml.dom.minidom import parse, parseString

class Info (threading.Thread):
def __init__ (self):
threading.Thread.__init__ (self)
def run (self):
print ''In Another Thread...''
pythoncom.CoInitialize ()
dom1 = parse(''processTerminateList.xml'')
config_element = dom1.getElementsByTagName("processTerminateList")
[0]
servers = config_element.getElementsByTagName("processName")
try:
c = wmi.WMI ()
for process in c.Win32_Process ():
for server in servers:
if process.name == getText(server.childNodes):
process.Terminate()
print process.name
process_watcher = c.Win32_Process.watch_for("creation")
while True:
new_process = process_watcher()
name = new_process.Caption
print name
for server in servers:
if name == getText(server.childNodes):
new_process.Terminate()
finally:
pythoncom.CoUninitialize ()
def getText(nodelist):
rc = ""
for node in nodelist:
if node.nodeType == node.TEXT_NODE:
rc = rc + node.data
return rc

if __name__ == ''__main__'':
Info().start()
------------------------------------------------------
processTerminateList.xml-----------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<processTerminateList>
<processName>scrcons.exe</processName>
<processName>TXPlatform.exe</processName>
<processName>mdm.exe</processName>
<processName>FNPLicensingService.exe</processName>
<processName>notepad.exe</processName>
<processName>uedit32.exe</processName>
</processTerminateList>



您应该将此发布到comp.python.windows。 Tim Golden(WMI的作者

界面)监控这个列表(感谢蒂姆)。


-Larry

You should probably post this to comp.python.windows. Tim Golden (author of WMI
interface) monitors that list religously (thanks Tim).

-Larry

On 7 ??13è?,????10ê±26·?, Larry Bates< larry.ba ... @ websafe.com`wrote:
On 7??13è?, ????10ê±26·?, Larry Bates <larry.ba...@websafe.com`wrote:

patrol写道:
patrol wrote:

我想阻止某些进程运行。代码在

之后。我遇到了一些意想不到的麻烦。

Probelm1:这个程序无法终止scrcons.exe并且

FNPLicensingService.exe,这是系统进程。

问题2:过了一会儿,这个程序会因错误而中止

文件C:\Python25 \lib \ wmi.py,第397行,在__call__

handle_com_error(error_info)

文件C:\Python25 \ lib \ wmi.py",第190行,在handle_com_error中提升

x_wmi," \ n" .join(exception_string)

UnicodeDecodeError:''ascii ''编解码器无法解码位置上的字节0xb7

14:序数不在范围内(128)
I want to prevent some process from running. The code is in the
following. I encounter some unexpected troubles.
Probelm1: This program cannot terminate "scrcons.exe" and
"FNPLicensingService.exe",which are system processes.
Problem2:After a while, this program will abort by error
File "C:\Python25\lib\wmi.py", line 397, in __call__
handle_com_error (error_info)
File "C:\Python25\lib\wmi.py", line 190, in handle_com_error raise
x_wmi, "\n".join (exception_string)
UnicodeDecodeError: ''ascii'' codec can''t decode byte 0xb7 in position
14: ordinal not in range(128)


- -------------------------------------------------- -

代码---------------------------------------- -------------------------------------------

# - * - 编码:utf-8 - * -

导入pythoncom

导入wmi

导入线程

导入时间

来自xml.dom.minidom导入解析,parseSt ring
----------------------------------------------------
code-----------------------------------------------------------------------------------
# -*- coding:utf-8 -*-
import pythoncom
import wmi
import threading
import time
from xml.dom.minidom import parse, parseString


class Info(threading.Thread):

def __init__(self):

threading.Thread .__ init __(self)

def run(self):

print''在另一个线程......''

pythoncom.CoInitialize()

dom1 = parse(''processTerminateList.xml'')

config_element = dom1.getElementsByTagName(" processTerminateList")

[0]

servers = config_element.getElementsByTagName(" processName")

try:

c = wmi.WMI()

表示c.Win32_Process()中的进程:

表示服务器中的服务器:

if process.name == getText(server.childNodes):

process.Terminate()

print process.name

process_watcher = c.Win32_Process.watch_for(" creation")

而True:

new_process = process_watcher()

name = new_process.Caption

打印名称

服务器中的服务器:

if name == getText(server .childNodes):

new_process.Terminate()

终于:

pythoncom.CoUninitialize()

def getText (nodelist):

rc =""

节点列表中的节点:

if node.nodeType == node.TEXT_NODE:

rc = rc + node.data

返回rc
class Info (threading.Thread):
def __init__ (self):
threading.Thread.__init__ (self)
def run (self):
print ''In Another Thread...''
pythoncom.CoInitialize ()
dom1 = parse(''processTerminateList.xml'')
config_element = dom1.getElementsByTagName("processTerminateList")
[0]
servers = config_element.getElementsByTagName("processName")
try:
c = wmi.WMI ()
for process in c.Win32_Process ():
for server in servers:
if process.name == getText(server.childNodes):
process.Terminate()
print process.name
process_watcher = c.Win32_Process.watch_for("creation")
while True:
new_process = process_watcher()
name = new_process.Caption
print name
for server in servers:
if name == getText(server.childNodes):
new_process.Terminate()
finally:
pythoncom.CoUninitialize ()
def getText(nodelist):
rc = ""
for node in nodelist:
if node.nodeType == node.TEXT_NODE:
rc = rc + node.data
return rc


if __name__ ==''__ main__'':

Info()。start()

------------- -----------------------------------------

processTerminateList .XML ------------------------------------------------ ------------------------

<?xml version =" 1.0" encoding =" utf-8"?>

< processTerminateList>

< processName> scrcons.exe< / processName>

< processName> TXPlatform.exe< / processName>

< processName> mdm.exe< / processName>

< processName> FNPLicensingService.exe< / processName>

< processName> notepad.exe< / processName>

< processName> uedit32.exe< / processName>

< / processTerminateList>
if __name__ == ''__main__'':
Info().start()
------------------------------------------------------
processTerminateList.xml------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<processTerminateList>
<processName>scrcons.exe</processName>
<processName>TXPlatform.exe</processName>
<processName>mdm.exe</processName>
<processName>FNPLicensingService.exe</processName>
<processName>notepad.exe</processName>
<processName>uedit32.exe</processName>
</processTerminateList>



您应该将此发布到comp.python.windows。蒂姆·戈登(WMI的作者

界面)监视着这个名单(感谢蒂姆)。


-Larry-òt2?±?òyó???×? -


- ??ê?òyó?μ???×? -


You should probably post this to comp.python.windows. Tim Golden (authorof WMI
interface) monitors that list religously (thanks Tim).

-Larry- òt2?±?òyó???×? -

- ??ê?òyó?μ???×? -



我找不到comp.python.windows.What是URL?

I cannot find comp.python.windows.What''s the URL?


patrol写道:
patrol wrote:

On 7 ??13è?,????10ê±26·?, Larry Bates< larry.ba ... @ websafe.com`wrote :
On 7??13è?, ????10ê±26·?, Larry Bates <larry.ba...@websafe.com`wrote:

> patrol写道:
>patrol wrote:

>>我想阻止某些进程运行。代码在
下面。我遇到了一些意想不到的麻烦。
Probelm1:这个程序无法终止scrcons.exe。和/>FNPLicensingService.exe,它们是系统进程。
问题2:过了一段时间,这个程序将因错误而中止
文件C:\Python25 \lib \ wmi.py",第397行,在__call__
handle_com_error(error_info)
文件C:\Python25 \lib \ wmi.py,第190行,在handle_com_error中提升
x_wmi," \ n" .join(exception_string)
UnicodeDecodeError:''ascii''编解码器无法解码位置的字节0xb7
14:序数不在范围内(128)
------------------------------------------------- ---
代码------------------------------------------ -----------------------------------------
# - * - 编码:utf-8 - * -
导入pythoncom
导入wmi
导入线程
导入时间从xml.dom.minidom导入解析,parseString
类信息(threading.Thread):
def __init__(自我):
threading.Thread .__ init__(self)
def run(self):
prin t''在另一个线程中......''/ / pythoncom.CoInitialize()
dom1 = parse(''processTerminateList.xml'')
config_element = dom1.getElementsByTagName(" processTerminateList" )
[0]
servers = config_element.getElementsByTagName(" processName")
尝试:
c = wmi.WMI()
for c.Win32_Process中的进程():
服务器中的服务器:
如果process.name == getText(server.childNodes):
process.Terminate()
print process.name
process_watcher = c.Win32_Process.watch_for(" creation")
而True:
new_process = process_watcher()
name = new_process.Caption
服务器中服务器的打印名称:
如果name == getText(server.childNodes):
new_process.Terminate()
最后:
pythoncom.CoUninitialize()
def getText(nodelist):
rc =""
节点列表中的节点:
如果node.nodeType == node.TEXT_NODE:
rc = rc + node.data
返回rc
如果__name__ ==''__ main__'':
Info()。start()
----------- -------------------------------------------
processTerminateList.xml -------------------------------------------------- ----------------------
<?xml version =" 1.0" encoding =" utf-8"?>
< processTerminateList>
< processName> scrcons.exe< / processName>
< processName> TXPlatform.exe< / processName>
< processName> mdm.exe< / processName>
< processName> FNPLicensingService.exe< / processName>
< processName> notepad.exe< / processName>
< processName> uedit32.exe< / processName>
< / processTerminateList>
>>I want to prevent some process from running. The code is in the
following. I encounter some unexpected troubles.
Probelm1: This program cannot terminate "scrcons.exe" and
"FNPLicensingService.exe",which are system processes.
Problem2:After a while, this program will abort by error
File "C:\Python25\lib\wmi.py", line 397, in __call__
handle_com_error (error_info)
File "C:\Python25\lib\wmi.py", line 190, in handle_com_error raise
x_wmi, "\n".join (exception_string)
UnicodeDecodeError: ''ascii'' codec can''t decode byte 0xb7 in position
14: ordinal not in range(128)
----------------------------------------------------
code-----------------------------------------------------------------------------------
# -*- coding:utf-8 -*-
import pythoncom
import wmi
import threading
import time
from xml.dom.minidom import parse, parseString
class Info (threading.Thread):
def __init__ (self):
threading.Thread.__init__ (self)
def run (self):
print ''In Another Thread...''
pythoncom.CoInitialize ()
dom1 = parse(''processTerminateList.xml'')
config_element = dom1.getElementsByTagName("processTerminateList")
[0]
servers = config_element.getElementsByTagName("processName")
try:
c = wmi.WMI ()
for process in c.Win32_Process ():
for server in servers:
if process.name == getText(server.childNodes):
process.Terminate()
print process.name
process_watcher = c.Win32_Process.watch_for("creation")
while True:
new_process = process_watcher()
name = new_process.Caption
print name
for server in servers:
if name == getText(server.childNodes):
new_process.Terminate()
finally:
pythoncom.CoUninitialize ()
def getText(nodelist):
rc = ""
for node in nodelist:
if node.nodeType == node.TEXT_NODE:
rc = rc + node.data
return rc
if __name__ == ''__main__'':
Info().start()
------------------------------------------------------
processTerminateList.xml------------------------------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<processTerminateList>
<processName>scrcons.exe</processName>
<processName>TXPlatform.exe</processName>
<processName>mdm.exe</processName>
<processName>FNPLicensingService.exe</processName>
<processName>notepad.exe</processName>
<processName>uedit32.exe</processName>
</processTerminateList>


您应该将此发布到comp.python.windows。 Tim Golden(WMI
界面的作者)监视着这些名单(感谢蒂姆)。

-Larry-òt2?±?òyó???×? -

- ??ê?òyó?μ???×? -

You should probably post this to comp.python.windows. Tim Golden (author of WMI
interface) monitors that list religously (thanks Tim).

-Larry- òt2?±?òyó???×? -

- ??ê?òyó?μ???×? -



我找不到comp.python.windows.What是什么网址?


I cannot find comp.python.windows.What''s the URL?

http:// news.gmane.org/gmane.comp.pyt...ws/cutoff=7565


-Larry

http://news.gmane.org/gmane.comp.pyt...ws/cutoff=7565

-Larry


这篇关于关于wmi的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆