重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
怎么在vbs中实现一个tasklist效果?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
创新互联公司是一家集网站建设,察雅企业网站建设,察雅品牌网站建设,网站定制,察雅网站建设报价,网络营销,网络优化,察雅网站推广为一体的创新建站企业,帮助传统企业提升企业形象加强企业竞争力。可充分满足这一群体相比中小企业更为丰富、高端、多元的互联网需求。同时我们时刻保持专业、时尚、前沿,时刻以成就客户成长自我,坚持不断学习、思考、沉淀、净化自己,让我们为更多的企业打造出实用型网站。核心代码
Option explicit If right(Ucase(WScript.FullName),11)="WSCRIPT.EXE" Then wscript.echo "You should run this script from the command line (cmd)" & vbCrLf & "cscript " & wscript.ScriptFullName WScript.Quit End If dim strComputer,objWMIService,colProcesses,objProcess,ProcessTime,strCreationDate,user,Domain,strOwner,h,m,s,chaine strComputer = "." Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colProcesses = objWMIService.ExecQuery ("Select * from Win32_Process") ' where Name='IEXPLORE.EXE' Chaine="Process |Creation Date Time |Handles|Threads|Owner |Priority|MemoryUsage|MaxMemUsage|MemRequired|MaxMemRequi| Swap| Max Swap|CPU time|PID |PFaults|Path" & vbCrLf For Each objProcess in colProcesses If objProcess.GetOwner ( User, Domain ) = 0 Then strOwner= Domain & "\" & User Else strOwner="Unknown" End If ProcessTime=(CSng(objProcess.KernelModeTime) + CSng(objProcess.UserModeTime)) / 10000000 h=right("0" & fix(ProcessTime/60/60),2) ProcessTime=ProcessTime-h*60*60 m=right("0" & fix(ProcessTime/60),2) s=Right("0" & round(ProcessTime-m*60),2) strCreationDate=Mid(objProcess.CreationDate,7,2) & "/" & Mid(objProcess.CreationDate,5,2) & "/" & Left(objProcess.CreationDate,4) & " " & Mid(objProcess.CreationDate,9,2) & ":" & Mid(objProcess.CreationDate,11,2) & ":" & Mid(objProcess.CreationDate,13,2) If strCreationDate="// ::" Then strCreationDate=Space(19) Chaine=Chaine & Left(objProcess.Name & space(8),12) & "|" _ & strCreationDate & "|" & Right(Space(6) & objProcess.HandleCount,7) & "|" _ & Right(Space(6) & objProcess.ThreadCount,7) & "|" _ & Left(strOwner & space(14),19) & "|" _ & Left(objProcess.Priority & Space(7),8) & "|" _ & Right(Space(10) & objProcess.PageFileUsage ,11) & "|" _ & Right(Space(10) & objProcess.PeakPageFileUsage ,11) & "|" _ & Right(Space(8) & objProcess.WorkingSetSize ,11) & "|" _ & Right(Space(8) & objProcess.PeakWorkingSetSize ,11) & "|" _ & Right(Space(10) & objProcess.VirtualSize ,11) & "|" _ & Right(Space(10) & objProcess.PeakVirtualSize ,11) & "|" _ & h & ":" & m & ":" & s & "|" _ & Left(objProcess.ProcessID & space(3),4) & "|" _ & Right(Space(6) & objProcess.PageFaults ,7) & "|" & objProcess.ExecutablePath Chaine=Chaine & vbCrLf Next wscript.echo chaine
看完上述内容,你们掌握怎么在vbs中实现一个tasklist效果的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注创新互联行业资讯频道,感谢各位的阅读!