用VBA来关闭其他程序

以关闭Winrar.exe为例,代码如下:

Sub closeWinrar()
         Dim oWMT As Object, oProcess As Object
         Set oWMT = GetObject( "winmgmts://")
         For Each oProcess In oWMT.InstancesOf( "Win32_Process")
                 If LCase(oProcess.Name) = "winrar.exe" Then
                         If oProcess.Terminate() = 0 Then Exit Sub
                 End If
         Next
End Sub


作者:laoyebin(Paladin.lao)
博客园出处: http://www.cnblogs.com/laoyebin/
个人网站英文出处: http://mrvsto.com/
个人网站中文出处: http://cn.mrvsto.com/

你可能感兴趣的:(职场,VBA,休闲)