Read machine process information via Psutil module:
#-*-Coding:utf-8-*-
Import Psutil;
Import OS
Import Commmethod
"Get information about the machine's current process"
Def getcurrentprocessinfo ():
lst1= Psutil.pids ()
Lst1.sort ()
For I in Lst1:
temp = ""
Flag=true
# file name
filename = psutil. Process (i). Name ()
#文件全路径
FilePath = ""
#文件版本号
Version = ""
#安装时间
Installtime = ""
#访问时间
Accesstime = ""
#启动时间
StartTime = ""
Try
#文件路径
filepath = Psutil. Process (i). exe ()
#启动时间
StartTime = Commmethod.timestamptotime (psutil. Process (i). Create_time ())
#版本信息
Version = Commmethod.getfileversion (filepath)
Installtime = Os.path.getctime (filepath)
Accesstime = Os.path.getatime (filepath)
#把时间戳转为时间格式
Installtime = Commmethod.timestamptotime (installtime)
Accesstime = Commmethod.timestamptotime (accesstime)
Except
Flag=false
Finally
if (len (version) >0 and Len (installtime) >0):
print ' Id=%d,name=%s,filename =%s,version=%s, installtime=%s,accesstime=%s,starttime =%s '% (i,psutil. Process (i). Name (), Filename,version,installtime,accesstime,starttime)
Getcurrentprocessinfo ()
Python process information