网上原码,去了DECODE编码的问题。

PyScripter这个PYTHON的IDE工具在WIN下表现不错哟。

感觉比SPYDER,ERIC,SUBLEME TEXT3之类的好用呀。。

#!/usr/bin/env python
# -*- coding: utf-8 -*-

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,"Vernum:%s" % sys.BuildNumber
        print  sys.OSArchitecture#系统是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)
            break

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, partition.Caption, 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, s.Caption, s.Command)

    #获取当前运行的进程
    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 + PYWIN32 + WMI获取WINDOWS系统基本信息的更多相关文章

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

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

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

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

  3. Python使用WMI模块获取Windows系统的硬件信息,并使用pyinstaller库编译打包成exe的可执行文件

    由于公司现阶段大多数应用软件都是基于Windows系统开发和部署,很多软件安装部署都是在windows server 2012.windows server 2008之类的服务器上,部门同事每次测试一 ...

  4. 获取Windows系统中的所有可用和在用串口

    目的:获取Windows系统中的所有可用和在用串口 方法:注册表查询法 优点:简单.实用.快速.无遗漏,无多余结果. 说明:另外还有8种方法可以枚举串口,但都不如此法. 代码和详细注释如下: //-- ...

  5. 通过PowerShell获取Windows系统密码Hash

    当你拿到了系统控制权之后如何才能更长的时间内控制已经拿到这台机器呢?作为白帽子,已经在对手防线上撕开一个口子,如果你需要进一步扩大战果,你首先需要做的就是潜伏下来,收集更多的信息便于你判断,便于有更大 ...

  6. [源码]一键获取windows系统登陆密码vc6版源码

    [源码]一键获取windows系统登陆密码vc6版源码支持:XP/2000/2003/WIN7/2008等 此版本编译出来的程序体积较小几十KB... 而vs版则1点几M,体积整整大了2-30倍对某些 ...

  7. C/C++获取Windows系统CPU和内存及硬盘使用情况

    //1.获取Windows系统内存使用率 //windows 内存 使用率 DWORD getWin_MemUsage(){ MEMORYSTATUS ms; ::GlobalMemoryStatus ...

  8. 这段百度问答,对我相关有对啊!!!----如何获取Windows系统登陆用户名

    如何获取Windows系统登陆用户名 http://zhidao.baidu.com/link?url=Hva9PkVwYZv8KSEWftSqTWe8fqM1dhoq59BurnfADmcOvFjF ...

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

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

随机推荐

  1. install lua client for redis-server on Mac

    1. lua client library for redis-server https://github.com/nrk/redis-lua 2. dependent luasocket https ...

  2. ASP.NET Mvc开发之EF延迟加载

    EF延迟加载:就是使用Lamabda表达式或者Linq 从 EF实体对象中查询数据时,EF并不是直接将数据查询出来,而是在用到具体数据的时候才会加载到内存. 一,实体对象的Where方法返回一个什么对 ...

  3. Android的Manifest配置文件介绍

    一.关于AndroidManifest.xml       AndroidManifest.xml 是每个android程序中必须的文件.它位于整个项目的根目录,描述了package中暴露的组件(ac ...

  4. Extjs combobox设置默认值

    转载:http://www.54mask.com/extjs-combobox-default-value.html 相信很多人都遇到了在ExtJS框架中设置combo组件默认值的需求,ExtJS框架 ...

  5. JDK+Tomcat+MyEclipse发布JSP项目——不能成功的问题

    JDK.Tomcat和MyEclipse安装完成后,在将web Project发布到Tomcat时出现金叹号,如图 原因:由于将Tomcat安装在C盘,所以需要启用管理员权限. 解决途径:用管理员身份 ...

  6. JDBC——数据层DAO

    DAO:Data Access Object DAO 数据层 Service 逻辑业务层 View  视图层 entity   实体层 实现增.删.改.查的数据层 public class EmpDA ...

  7. 无可匹敌的创建job(细化很多细节)

    declare  jobno           binary_integer ;  rm_days         number := 15; --保留多少天的数据,单位天数  rm_hour    ...

  8. Leaflet交流

    GIS科研网 Leaflet交流 谢绝转载 http://www.3sbase.com欢迎加群交流  108299288 http://www.3sbase.com/3sbase/webgistest ...

  9. 微软AJAX解决方案

    -------- 微软AJAX解决方案 (*) --------ASP.Net中内置的简化AJAX开发的控件UpdatePanel 放入ScriptManager,将要实现AJAX效果的控件放到Upd ...

  10. 嵌入式linux无线网卡的使用

    from:http://blog.csdn.net/sparksalmon/article/details/8445287 嵌入式linux无线网卡的使用 最近一直在开发机顶盒上的无线功能,把这一段的 ...