Excel宏来检查后台Power Shell脚本

时间:2017-12-12 07:02:31

标签: excel-vba vba excel

你能帮我写一个excel宏来检查;是否有任何后台Power Shell脚本在机器上运行?

谢谢, Aneesh

1 个答案:

答案 0 :(得分:0)

Sub IsPowerShellRunning()
    Debug.Print IsProcessRunning("powershell.exe")
End Sub

Function IsProcessRunning(process As String) as Boolean
    Dim objList As Object

    Set objList = GetObject("winmgmts:") _
        .ExecQuery("select * from win32_process where name='" & process & "'")
    If objList.Count > 0 Then
        IsProcessRunning = True
    Else
        IsProcessRunning = False
    End If

End Function

<子>(Source