Python calls Win32com.client's GetObject to find process information and service information

Source: Internet
Author: User

Why not use WMI? Because the execution is very slow, why not winreg? Because WinReg is inconvenient in terms of bulk acquisition and traversal of services, this method is used

This method is executed with WMIC under the command line

Get Service Information

# Coding=utf8  from Import  = GetObject ("winmgmts:"= mywmi. InstancesOf ("win32_service" for in OBJS:     Print

Get process Information

# Coding=utf8
from Import = GetObject ("winmgmts:"= mywmi. InstancesOf ("win32_process" for in OBJS: # Print

The code of execution is inspired by the following text:

VB use WMI to get the system current process details/list, VB use WMI to get the system current process information/list, VB use WMI to get the system process information/list, VB use WMI to get the current process information/list, VB use WMI to get process information/list, VB WMI Get current process information/list, VB WMI system process details/list, VB WMI process list, VB WMI process information, VB WMI process, VB Wmi,getobject ("winmgmts://./root/cimv2:win32_process"). Instances,winmgmts://./ROOT/CIMV2:WIN32_PROCESS,VB winmgmts://./root/cimv2,vb Win32_process,vb GetObject, Process Name: wmi.name, Process path: Wmi.executablepath, number of threads: wmi.threadcount,pid:wmi.processid, parent PID:Wmi.ParentProcessID, Priority: wmi.priority, command Line: Wmi.commandline, Memory consumption: wmi.workingsetsize/1024 & "K", User name: Wmi.execmethod_ ("GetOwner"). User, Startup time: Wmi.creationdate, another way to get the PID function: Wmi.handle. VB uses WMI to get the current process details of the system: Dim Wmi, Jic as Stringfor each Wmi in GetObject ("winmgmts://./root/cimv2:win32_process"). Instances_'Looping ProcessJic = Jic &" "& _"Process:"& Wmi.name &" "& _"Path:"& Wmi.executablepath &" "& _"Threads:"& Wmi.threadcount &" "& _"PID:"& Wmi.processid &" "& _"Parent PID:"& Wmi.parentprocessid &" "& _"Priority level:"& Wmi.priority &" "& _"command line:"& Wmi.commandline &" "& _"Memory:"& Wmi.workingsetsize/1024x768&"K"&" "& _"User:"& Wmi.execmethod_ ("GetOwner"). User &" "& _"Start time:"& Wmi.creationdate &" "&vbCrLf'"PID:" & Wmi.handle'another kind of acquiring PID function NextMsgBox JICVB"winmgmts://./root/cimv2"detailed usage of the object: • GetOwner () Gets the process user name. Usage: Objgetowner (variable name) Terminate () end process. Usage: obj. Terminate () Property: PID of the ProcessID process. Number of threads ThreadCount process ExecutablePath The full path of the process

Python calls Win32com.client's GetObject to find process information and service information

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.