时间:2021-05-22
This short script uses WMI to display the same information than in the tool "tasklist", but dumping the result on the console. It can dump remote tasks running on another computer,
这个简短的脚本使用wmi显示与工具“tasklist”中相同的信息,但只有在命令行下输出结果。它也可以在另一台计算机上查看远程任务,
文件名:tasklist.vbs
要求:无
作者:Jean-Luc Antoine
提交日期:2005年7月14日
类别:4K
核心代码
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.QuitEnd Ifdim strComputer,objWMIService,colProcesses,objProcess,ProcessTime,strCreationDate,user,Domain,strOwner,h,m,s,chainestrComputer = "." 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代码运行方法,将上面的代码为tasklist.vbs
在cmd下 cscript tasklist.vbs 即可,也可以在cmd下 cscript tasklist.vbs >list.txt直接将结果保存为list.txt查看也比较容易
好了,代码到此结束
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
运行效果图:代码(monprocess.vbs):复制代码代码如下:OnErrorResumeNextstrComputer="."arrTargetProcs
运行效果:代码(fOutput.vbs):复制代码代码如下:strComputer="."SetobjWMIService=GetObject("winmgmt
效果图:代码(checksvr.vbs):复制代码代码如下:'OnErrorResumeNextConstHKEY_LOCAL_MACHINE=&H800000
复制代码代码如下:'执行方法:直接双击vbs文件或者通过cmd.exe下cscript.exe"指定脚本的路径"'利用Vbs脚本实现显示系统服务里表'Creat
VBS正则表达式函数主要用在asp中效果明显1、表单验证功能复制代码代码如下:FunctionValidate(strng,patrn)DimregExSetr