Answer the question
In order to leave comments, you need to log in
One element must be selected. How to do without a cycle?
I'm trying to extract the login of the user who is currently working for the PC hostname
import wmi
wmiConn = wmi.WMI(hostname)
for cs in wmiConn.Win32_ComputerSystem():
curUser = cs.UserName
Why in this case it is impossible to write: curUser = wmiConn.Win32_ComputerSystem().UserName ?
Answer the question
In order to leave comments, you need to log in
Why can't you select an element by index?
import wmi
wmiConn = wmi.WMI(hostname)
curUser = wmiConn.Win32_ComputerSystem()[0].UserName
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question