Jump to content
Sign in to follow this  

Processclose in Windows 7

Recommended Posts



I love AutoIt for years and use it every now and then when i get an idea to program.

Right now i am using Windows 7 and i am not able to close an "iexplore.exe *32" process in the way i did with WinXP

in the Windows Taskmanager i get listed "iexplore.exe *32" so i tried



ProcessClose("iexplore.exe *32")

but nothing happened!

i already used the search funktion as i did the years before but this time i found really nothing to solve my problem.

any ideas?


- Greets Lars -

Share this post

Link to post
Share on other sites

just found out i can list the iexplore processes including the PID by using the "ProcessList" example script from the AutoIt Help like this:

$list = ProcessList("iexplore.exe")
for $i = 1 to $list[0][0]
  msgbox(0, $list[$i][0], $list[$i][1])

so .. when i can get a list of "iexplore.exe" why isn´t it possible to ProcessClose iexplore.exe!?

Share this post

Link to post
Share on other sites

Did some research, interesting ;).IE8 spawns multiple instances of itself to handle the tabs. You have to close the parent instance to properly close IE. Added some links in the example.

; http://www.winhelponline.com/blog/multiple-instances-of-iexploreexe-run-when-using-internet-explorer-8/

; IE8 and Loosely-Coupled IE (LCIE)
; http://blogs.msdn.com/ie/archive/2008/03/11/ie8-and-loosely-coupled-ie-lcie.aspx

;#include <array.au3>
#include <Process.au3>

$list = ProcessList("iexplore.exe")
if $list[0][0] > 0 Then
    for $i = 1 to $list[0][0]
        ;MsgBox(0,"",$list[$i][1] & @crlf & _ProcessGetParent($list[$i][1]) & @crlf & _ProcessGetName(_ProcessGetParent($list[$i][1])))
        if _ProcessGetName(_ProcessGetParent($list[$i][1])) = "explorer.exe" then ProcessClose($list[$i][1])

; Function Name:    _ProcessGetParent()
; Description:      Retrieve parent process for a child process
; Parameter(s):     $i_pid: The process identifier of the process you want to get the parent
;                       process identifier for
; Return Value(s):
;                 On Success:
;                   Parent PID (process identifier)
;                 On Failure:
;                   PID of process passed (Check @error to make sure it is a parent and didn't
;                       fail)
;                 @Error:
;                   (1): CreateToolhelp32Snapshot failed
;                   (2): Process32First failed
; Remark(s):        Tested on Windows XP SP2
; Author(s):        SmOke_N (Ron Nielsen)

Func _ProcessGetParent($i_pid)
    Local Const $TH32CS_SNAPPROCESS = 0x00000002

    Local $a_tool_help = DllCall("Kernel32.dll", "long", "CreateToolhelp32Snapshot", "int", $TH32CS_SNAPPROCESS, "int", 0)
    If IsArray($a_tool_help) = 0 Or $a_tool_help[0] = -1 Then Return SetError(1, 0, $i_pid)

    Local $tagPROCESSENTRY32 = _
        DllStructCreate _
            ( _
                "dword dwsize;" & _
                "dword cntUsage;" & _
                "dword th32ProcessID;" & _
                "uint th32DefaultHeapID;" & _
                "dword th32ModuleID;" & _
                "dword cntThreads;" & _
                "dword th32ParentProcessID;" & _
                "long pcPriClassBase;" & _
                "dword dwFlags;" & _
                "char szExeFile[260]" _
    DllStructSetData($tagPROCESSENTRY32, 1, DllStructGetSize($tagPROCESSENTRY32))

    Local $p_PROCESSENTRY32 = DllStructGetPtr($tagPROCESSENTRY32)

    Local $a_pfirst = DllCall("Kernel32.dll", "int", "Process32First", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32)
    If IsArray($a_pfirst) = 0 Then Return SetError(2, 0, $i_pid)

    Local $a_pnext, $i_return = 0
    If DllStructGetData($tagPROCESSENTRY32, "th32ProcessID") = $i_pid Then
        $i_return = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID")
        DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0])
        If $i_return Then Return $i_return
        Return $i_pid

    While 1
        $a_pnext = DLLCall("Kernel32.dll", "int", "Process32Next", "long", $a_tool_help[0], "ptr", $p_PROCESSENTRY32)
        If IsArray($a_pnext) And $a_pnext[0] = 0 Then ExitLoop
        If DllStructGetData($tagPROCESSENTRY32, "th32ProcessID") = $i_pid Then
            $i_return = DllStructGetData($tagPROCESSENTRY32, "th32ParentProcessID")
            If $i_return Then ExitLoop
            $i_return = $i_pid

    If $i_return = "" Then $i_return = $i_pid

    DllCall("Kernel32.dll", "int", "CloseHandle", "long", $a_tool_help[0])
    Return $i_return

Share this post

Link to post
Share on other sites

Wow O_o

thats lots of stuff to close a window ;)

Thanks for your big help!

i will go and study your work now (i like to understand what i do!)

Thanks Thanks Thanks!

- Lars -

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.