Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/clojure/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
获取使用VBScript/JScript启动(例如)iexplore的进程_Vbscript_Wmi_Jscript - Fatal编程技术网

获取使用VBScript/JScript启动(例如)iexplore的进程

获取使用VBScript/JScript启动(例如)iexplore的进程,vbscript,wmi,jscript,Vbscript,Wmi,Jscript,有没有办法(最好使用VBScript/JScript这样的脚本语言)获取生成不同程序的进程的详细信息,例如,当ComputeTrace LoJack启动iexplore时,可以处理与internet的通信?您可以使用WMI检查感兴趣进程的ParentProcessId。对于“正常”用户模式应用程序,父进程应为explorer.exe strProcess = "iexplore.exe" strComputer = "." Set objWMIService = GetObject("winmg

有没有办法(最好使用VBScript/JScript这样的脚本语言)获取生成不同程序的进程的详细信息,例如,当ComputeTrace LoJack启动iexplore时,可以处理与internet的通信?

您可以使用WMI检查感兴趣进程的ParentProcessId。对于“正常”用户模式应用程序,父进程应为explorer.exe

strProcess = "iexplore.exe"
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process " _
    & " Where name = '" & strProcess & "'")

For Each objProcess in colProcesses
    WScript.Echo objProcess.ParentProcessId
Next
对于Internet Explorer,请确保您也检查了IE的ID,因为它会生成自身的多个实例。试着这样做:

strProcess = "iexplore.exe"
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process " _
    & " Where name = 'explorer.exe' OR name = 'iexplore.exe'")

i = 0
arrIds = Array()
For Each objProcess in colProcesses
    ReDim Preserve arrIds(i)
    arrIds(i) = objProcess.ProcessId
    i = i + 1
Next

Set colProcesses = objWMIService.ExecQuery("Select * from Win32_Process " _
    & " Where name = '" & strProcess & "'")

For Each objProcess in colProcesses
    intParentID = objProcess.ParentProcessId

    blnIsFound = False
    For Each intID in arrIds
        If intID = intParentID Then
            blnIsFound = True
            Exit For
        End If
    Next

    If blnIsFound = False Then
        WScript.Echo "Process " & objProcess.ProcessId & " spawned by process " & objProcess.ParentProcessId
    End If
Next

感谢@Nilipo,但是,在第二次查看(以及第三次、第四次等)时,我似乎无法找到您答案的第二个脚本想法找到IE父进程的(真实)ID的方法。在我看来,它似乎用iexplore/explorer进程的PID填充了一个数组,然后将这些PID与指定程序的父进程ID进行比较(根据我的问题-iexplore)。实际上,这似乎是在输出父iexplore的许多正在运行的进程的所有子进程(因为这是一个使用iexplore的未知程序,而不是strProcess=iexplore),或者我误读了?@user66001我输入了一个错误。我应该在最后检查这个假案子。换句话说,不是由Explorer.exe或Iexplore.exe生成的所有Iexplore.exe实例。这应该包括你要找的那个。