#!/usr/bin/env python
# -*- coding: utf-8 -*-
#http://www.cnblogs.com/liu-ke/
import wmi
import os
import sys
import platform
import time def sys_version():
c = wmi.WMI ()
#获取操作系统版本
for sys in c.Win32_OperatingSystem():
print "Version:%s" % sys.Caption.encode("UTF8"),"Vernum:%s" % sys.BuildNumber
print sys.OSArchitecture.encode("UTF8")#系统是32位还是64位的
print sys.NumberOfProcesses #当前系统运行的进程总数 def cpu_mem():
c = wmi.WMI ()
#CPU类型和内存
for processor in c.Win32_Processor():
#print "Processor ID: %s" % processor.DeviceID
print "Process Name: %s" % processor.Name.strip()
for Memory in c.Win32_PhysicalMemory():
print "Memory Capacity: %.fMB" %(int(Memory.Capacity)/1048576) def cpu_use():
#5s取一次CPU的使用率
c = wmi.WMI()
while True:
for cpu in c.Win32_Processor():
timestamp = time.strftime('%a, %d %b %Y %H:%M:%S', time.localtime())
print '%s | Utilization: %s: %d %%' % (timestamp, cpu.DeviceID, cpu.LoadPercentage)
time.sleep(5) def disk():
c = wmi.WMI ()
#获取硬盘分区
for physical_disk in c.Win32_DiskDrive ():
for partition in physical_disk.associators ("Win32_DiskDriveToDiskPartition"):
for logical_disk in partition.associators ("Win32_LogicalDiskToPartition"):
print physical_disk.Caption.encode("UTF8"), partition.Caption.encode("UTF8"), logical_disk.Caption #获取硬盘使用百分情况
for disk in c.Win32_LogicalDisk (DriveType=3):
print disk.Caption, "%0.2f%% free" % (100.0 * long (disk.FreeSpace) / long (disk.Size)) def network():
c = wmi.WMI ()
#获取MAC和IP地址
for interface in c.Win32_NetworkAdapterConfiguration (IPEnabled=1):
print "MAC: %s" % interface.MACAddress
for ip_address in interface.IPAddress:
print "ip_add: %s" % ip_address
print #获取自启动程序的位置
for s in c.Win32_StartupCommand ():
print "[%s] %s <%s>" % (s.Location.encode("UTF8"), s.Caption.encode("UTF8"), s.Command.encode("UTF8")) #获取当前运行的进程
for process in c.Win32_Process ():
print process.ProcessId, process.Name def main():
sys_version()
cpu_mem()
#disk()
#network()
#cpu_use() if __name__ == '__main__':
main()
print platform.system()
print platform.release()
print platform.version()
print platform.platform()
print platform.machine()

Python WMI获取Windows系统信息的更多相关文章

  1. Python WMI获取Windows系统信息 监控系统

    #!/usr/bin/env python # -*- coding: utf-8 -*- #http://www.cnblogs.com/liu-ke/ import wmi import os i ...

  2. Python使用wmi获取Windows相关信息

    在使用Python获取Windows系统上的相关的信息可以使用WMI接口来获取, 什么是wmi? WMI是一项核心的Windows管理技术,WMI作为一种规范和基础结构,通过它可以访问.配置.管理和监 ...

  3. 用PYTHON + PYWIN32 + WMI获取WINDOWS系统基本信息

    网上原码,去了DECODE编码的问题. PyScripter这个PYTHON的IDE工具在WIN下表现不错哟. 感觉比SPYDER,ERIC,SUBLEME TEXT3之类的好用呀.. #!/usr/ ...

  4. 利用python 与 wmi 获取WINDOWS基本信息

    #!/usr/bin/env python3.5 # -*- coding:utf8 -*- import platform import subprocess import wmi def serv ...

  5. Python的功能模块[0] -> wmi -> 获取 Windows 内部信息

    wmi模块 / wmi Module WMI (Windows Management Instrumentation) 模块可用于获取 Windows 内部信息.该模块需要 win32com 的支持, ...

  6. 几个获取Windows系统信息的Delphi程序

    1.获取windows版本信息 可以通过Windows API函数GetVersionEx来获得. 具体程序如下: Procedure Tform1.Button1Click(sender:TObje ...

  7. python写的用WMI检测windows系统信息的脚本

    脚本如下: #!/usr/bin/env python #coding:utf- import wmi import sys,time,platform def get_system_info(os) ...

  8. 获取windows系统信息

    在应用程序中,有时需要在界面中显示计算机的硬件信息和进程信息.在.Net中提供了可以查询信息的类.Management类,在程序中添加应用后进行使用. 1 属性 类似的属性介绍可见下面: 属性介绍 根 ...

  9. python - 练习(获取windows硬件信息)

    import subprocess import re # info = subprocess.Popen("systeminfo",shell=True,stdout=subpr ...

随机推荐

  1. django auth permission

    django 提供内置view处理登陆和退出. 查看django.contrib.auth源码,主要查看三个函数authenticate,login,logout. authenticate(requ ...

  2. 51Nod--1247 可能的路径(gcd)

    根据规则可知 假设 (a,b) 可以到达坐标(aa,bb) 那么 aa=a*x+b*y  x y 必定有解  所以 我们只要求两个坐标的gcd看是否相等就好 #include<bits/stdc ...

  3. SpringMVC中使用 MultipartFile 进行文件上传下载及删除

    一:引入必要的包 <!--文件上传--> <!-- https://mvnrepository.com/artifact/commons-fileupload/commons-fil ...

  4. css实现文本两端对齐

    display:inline-block; text-align:center; text-align-last:justify;

  5. 数据库导出excel,前后端分离

    主要参考了这篇博文:https://www.cnblogs.com/jerehedu/p/4343509.html  2.3和2.4 采用xssf,依赖:compile group: 'org.apa ...

  6. 剑指Offer_编程题_22

    题目描述 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序.假设压入栈的所有数字均不相等.例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序 ...

  7. css样式关键字(initial,inherit,unset,revert,all)

    关键字 在CSS中,有4个关键字理论上可以应用于任何的CSS属性,它们是initial(初始).inherit(继承).unset(未设置).revert(还原).而all的取值只能是以上这4个关键字 ...

  8. [物理学与PDEs]第1章第8节 静电场和静磁场 8.2 稳定电流的电场

    1. 此时, Maxwell 方程组为 $$\beex \bea \Div{\bf D}&=\rho_f,\\ \rot {\bf E}&={\bf 0},\\ \Div{\bf B} ...

  9. 11招玩转黑客攻防——用Python,更安全

    Python真是无所不能,学习Python,一个暑假就够了 !! 入门Python,从黑客入手最好玩.最简单 !! 今天就推荐一本书<11招玩转网络安全——用Python,更安全> 内网攻 ...

  10. Java(6)for循环

    一.for循环的使用场合 1.1.while循环——先判断,再循环 while(1.条件表达式){      //2.循环操作      //3.更改循环条件表达式 } 1.2.do…while——先 ...