How to get Windows host information remotely in Python
How to obtain Windows host information remotely in Python? for this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more partners who want to solve this problem to find a more simple and feasible method.
Get Windows host information
WMI (Windows Management Instrumentation) is a core Windows management technology, and WMI module can be used to obtain internal information of Windows. As a specification and infrastructure, WMI can access, configure, manage and monitor almost all Windows resources, for example, users can start a process on a remote computing machine, set a process to run on a specific date and time, start the computer remotely, obtain a list of installed programs on the local or remote computer, query the Windows event log of the local or remote computer, and so on.
The following code is to get information about the Windows host.
Import wmiimport osimport socketw = wmi.WMI () # get computer user information for CS in w.Win32_ComputerSystem (): # print (CS) print ("computer name:% s"% CS.Caption) print ("user:% s"% CS.UserName) print ("manufacturer:% s"% CS.Manufacturer) print ("system Information:% s"% CS.SystemFamily) print ( "Workgroup:% s"% CS.Workgroup) print ("Machine Model:% s"% CS.model) print (") # get operating system information for OS in w.Win32_OperatingSystem (): # print (OS) print (" operating system:% s "% OS.Caption) print (" language version:% s "% OS.MUILanguages) print (" system digits: % s "% OS.OSArchitecture) print (" registrant:% s "% OS.RegisteredUser) print (" system driver:% s "% OS.SystemDevice) print (" system directory:% s "% OS.SystemDirectory) print (") # get computer IP and MAC information for address in w.Win32_NetworkAdapterConfiguration (ServiceName = "e1dexpress"): # print (address) print ("IP address:% s "% address.IPAddress) print (" MAC address:% s "% address.MACAddress) print (" Network description:% s "% address.Description) print (") # get computer CPU information for processor in w.Win32_Processor (): # print (processor) print ("CPU Model:% s"% processor.Name.strip ()) print ("CPU number:% s"% processor.NumberOfCores ) print (") # get BIOS information for BIOS in w.Win32_BIOS (): # print (BIOS) print (" use date:% s "% BIOS.Description) print (" Motherboard Model:% s "% BIOS.SerialNumber) print (" current language:% s "% BIOS.CurrentLanguage) print (") # get memory information for memModule in w.Win32_PhysicalMemory (): totalMemSize = int (memModule.Capacity) print ("memory vendor:% s"% memModule.Manufacturer) print ("memory model:% s"% memModule.PartNumber) print ("memory size:% .2fGB"% (totalMemSize/1024**3)) print (") # get disk information for disk in w.Win32_DiskDrive (): diskSize = int (disk.size) print (" disk name:% S "% disk.Caption) print (" hard disk model:% s "% disk.Model) print (" disk size:% .2fGB "% (diskSize/1024**3)) # get video card information for xk in w.Win32_VideoController (): print (" video card name:% s "% xk.name) print (") # get computer name and IPhostname = socket.gethostname () ip = socket.gethostbyname (hostname) print ("computer name:% s"% hostname) print ("IP address:% s"% ip)
The output is shown in the following figure:
This is the answer to the question about how to obtain Windows host information remotely in Python. I hope the above content can be of some help to you. If you still have a lot of doubts to be solved, you can follow the industry information channel to learn more about it.