怎么用几行代码就可以实行检测进程?
我刚学可以不经编译就可以单独运行VBS编程,现在想知道怎样可以实现检测系统中某进程,如果不存在就运行指定路径的程序。
菜鸟问题,希望大家不吝赐教。
[解决办法]
Sub Command3_Click()
Dim strComputer As String
Dim objWMIService As Object
Dim objProcess As Object
Dim colProcessList
On Error Resume Next
strComputer = ". "
Set objWMIService = GetObject( "winmgmts: " & "{impersonationLevel=impersonate}!\\ " & _
strComputer & "\root\cimv2 ")
Set colProcessList = objWMIService.ExecQuery( "select * FROM Win32_Process ")
For Each objProcess In colProcessList
enum1 = enum1 + objProcess.Name + ", "
enum1 = enum1 + CStr(objProcess.processid) + ", "
enum1 = enum1 + CStr(objProcess.workingsetsize) + ", "
enum1 = enum1 + Chr(13) + Chr(10)
Next
Debug.Print enum1
End Sub