[Tools]获取系统开关机信息(附源码及程序)
来源:互联网 发布:淘宝店邮费一般多少 编辑:程序博客网 时间:2024/06/18 04:05
博主写了一个小脚本/工具(Github下载地址包含全部源码及pyinstaller转的exe可执行程序),用来获取系统开关机信息,大家觉得不错就收下吧,欢迎交流提建议。
EventPowerStat.bat
@echo offcd %~dp0wevtutil qe system /format:text /q:"Event[System[(EventID=12 or EventID=13)]]" > EvtPower.datEventPowerStat.exe EvtPower.datdel /F EvtPower.dat
EventPowerStat.py
# -- coding:utf-8 --# Python v2.7.10# EventPowerStat.py# Written by Gaearrowimport sys# EventID to Task Dictionaryeventiddic = { '12':'PowerOn', '13':'PowerOff',}# Process Inputif len(sys.argv) != 2: print 'Usage: ' print 'wevtutil qe system /format:text /q:"Event[System[(EventID=12 or EventID=13)]]" > EvtPower.dat' print '%s EvtPower.dat' % sys.argv[0].split('\\')[-1] sys.exit(1)evt = sys.argv[1]fevt = open(evt,'r')fpower = open('PowerStat.csv','w')print >>fpower,'Event No.; Task; Date; Computer'try: # Perform the Statistics numevent = 0 numpoweron = 0 numpoweroff = 0 for eachline in fevt: if eachline.find('Event[') > -1: # Reset var evtno = '' date = '' task = '' computer = '' skip = 1 evtno = eachline.split('[')[1].split(']')[0] numevent = numevent + 1 elif eachline.find('Date:') > -1: date = eachline[(eachline.find(':')+1):].strip() elif eachline.find('Event ID') > -1: evtid = eachline.split(':')[1].strip() task = eventiddic[evtid] elif eachline.find('Level: Information') > -1: skip = 0 elif eachline.find('Computer:') > -1: computer = eachline.split(':')[1].strip() if skip == 0: print >>fpower,evtno+';'+task+';'+date+';'+computer if task == 'PowerOn': numpoweron = numpoweron + 1 else: numpoweroff = numpoweroff + 1 # Print Summary Infomation print >>fpower,'==============================' print >>fpower,'Summary Information' print >>fpower,'Power On Event : ',numpoweron print >>fpower,'Power Off Event : ',numpoweroff print >>fpower,'Total Event : ',numevent print >>fpower,'==============================' print 'Event Statistics Success to PowerStat.csv'except Exception as e: print 'Error: %s' % e sys.exit(1)fevt.close()fpower.close()
PowerStat.csv
Event No.; Task; Date; Computer0;PowerOff;2009-07-13T22:12:40.878;37L4247D25-071;PowerOn;2014-06-24T13:29:12.624;37L4247D25-072;PowerOff;2014-06-24T13:35:34.107;WIN-T6I0355NJEA3;PowerOn;2014-06-24T13:36:04.702;WIN-T6I0355NJEA4;PowerOff;2014-06-24T07:19:43.162;WIN-T6I0355NJEA5;PowerOn;2014-06-24T07:19:59.718;WIN-T6I0355NJEA6;PowerOff;2014-06-24T07:25:54.137;WIN-T6I0355NJEA...==============================Summary InformationPower On Event : 12Power Off Event : 12Total Event : 27==============================
0 0
- [Tools]获取系统开关机信息(附源码及程序)
- [Tools]获取域环境内所有用户登录信息(附源码及程序)
- Android JNI 练手实例(获取系统信息,附源码)
- 获取系统信息源码
- android 系统版本信息的获取(附修正时差)
- JAVA仿QQ聊天系统4.0(扩展韩顺平的程序的功能及界面)附源码
- 复制程序,获取系统信息
- {asp.net2.0}信息采集系统(附全部源码)
- 程序刻隆(源码)附解释
- 微信小程序电影推荐demo实战开发小结(附源码及思维导图) ... ...
- python 实现自动上传文件到百度网盘(附程序源码及实现过程)
- C#获取用户系统信息的程序
- C++程序获取系统信息方法
- java学生信息管理系统(附源码)
- Java 获取系统信息及Desktop类
- JavaScript 获取客户端计算机硬件及系统信息
- JavaScript 获取客户端计算机硬件及系统信息
- JavaScript 获取客户端计算机硬件及系统信息
- vi编辑器
- 简单Java类实训四(重难点)
- CentOS 7 配置Python语言开发环境
- androidStudio去掉标题栏,状态栏透明,状态栏不遮挡页面。
- LeetCode 206. Reverse Linked List
- [Tools]获取系统开关机信息(附源码及程序)
- BFC的形成条件和特性分析
- (codeforces)D. Cloud of Hashtags
- 数论之模加法运算
- git 命令--上传代码
- iOS
- 细说new与malloc的10点区别
- URL的组成格式
- 几种特殊的IPV4地址