I am trying to get the VM size of a running process and using the following simple script. Here initially I am trying to get the reference of that process. But getting the error as --
if "DomainManager" in c:
TypeError: argument of type 'NoneType' is not iterable
import wmi
computer = wmi.WMI ()
for process in computer.Win32_Process ():
c = process.CommandLine
if "DomainManager" in c:
print c
Would you please let me know the reason.
Thanks, Rag
import wmi
computer = wmi.WMI ()
for process in computer.Win32_Process ():
c = process.CommandLine
if c is not None and "DomainManager" in c:
print c
Notice the condition in the if statement:
if c is not None and "DomainManager in c":
This will check to see if c is valid before attempting to check if the given string is a substring of it.
Apparently, some processes have no CommandLine as far as WMI is concerned.
It appears
c = process.CommandLine
is setting c equal to None:
In [11]: "DomainManager" in None
TypeError: argument of type 'NoneType' is not iterable
I don't know anything about the Win32 API, so this is a complete guess, but you might try:
if c and "DomainManager" in c:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With