进程列表信息.vbs

strComputer = InputBox("请输入计算机名或者IP地址", "输入")


file = "d:\TaskInfo_" & strComputer & ".txt" '保存信息的文件名

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcessList = objWMIService.ExecQuery _
("Select * from Win32_Process")
Message = Message & vbCrlf & "以下为"& strComputer & "当前正在运行的进程列表:" & vbCrlf
Message = Message & "---------------------------------------------------" & vbCrLf & vbCrLf
For Each objProcess in colProcessList
Message = Message & "- " & objProcess.caption & vbcrlf & Space(15)
Message = Message & Standardoutput(objProcess.ExecutablePath) & vbcrlf
Next
'WScript.echo Message
Message = Message & vbcrlf & String(40,"-") & " 结束 " & String(40,"-") & vbcrlf
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(file, True)
objFile.write Message
Set objFile = nothing

Wscript.Echo strComputer & "当前正在运行的进程列表信息已存放在"& file

Function standardoutput(inputword)
If IsNull(inputword) Then
standardoutput = "系统进程"
Else
standardoutput = inputword
End If
End Function

你可能感兴趣的:(vbs)