Sign in to follow this  
Followers 0
Bi0haZarD

Close Handle of a Diffrent Program

9 posts in this topic

ok, not sure where to start with this one, but i'm hoping autoit can do this for me without the need of an external program..

If you've ever used process explorer from Sysinternals then this should make some sence, if you click on an active process the bottom window has some data down there, i need to be able to close a specific Handle of a specific program..

heres an example...

Posted Image

is that possible to do with autoit but without having to use send right clicks and stuff?

thanks

Share this post


Link to post
Share on other sites



anyone?

Share this post


Link to post
Share on other sites

Are you trying to close the Actual program? or just like the child window or other window within the same application?

If you just trying to close 1 application use

ProcessClose ( "process" )

Share this post


Link to post
Share on other sites

Have you tried using a combination of ProcessList()/WinList() to see if you can find the specific item that way?


[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

i tried the processclose and processlist, neither one is what i'm lookin for.

what i'm askin is every process runs multiple handles, such as in the screenshot above you can see the stuff in the bottom window, i need to be able to close the handle of a specific process without some external program (although i don't mind command line utilities as thats easy to do).

the program i want to do this on checks for a specific handle to prevent multi instances.. if i manually close that handle i can run multiple instances of the app. (yes i know theres other ways to get around that but i'm hoping i don't have to make multiple local accounts and so on.)

thanks

Share this post


Link to post
Share on other sites

i tried the processclose and processlist, neither one is what i'm lookin for.

what i'm askin is every process runs multiple handles, such as in the screenshot above you can see the stuff in the bottom window, i need to be able to close the handle of a specific process without some external program (although i don't mind command line utilities as thats easy to do).

the program i want to do this on checks for a specific handle to prevent multi instances.. if i manually close that handle i can run multiple instances of the app. (yes i know theres other ways to get around that but i'm hoping i don't have to make multiple local accounts and so on.)

thanks

My suggestion was not for ProcessList() alone, it was ProcessList()/WinList() combination. Have you tried that?

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

My suggestion was not for ProcessList() alone, it was ProcessList()/WinList() combination. Have you tried that?

This is actually what I had in Mind.. (Not sure it will still work, but at least it's more than what you have been offered to this point)
$GetWindowNamesAndHandles = GetWindowsFromEXE(ProcessExists('explorer.exe')); replace explorer with your actual exe name
For $x = 1 To UBound($GetWindowNamesAndHandles) - 1
    ConsoleWrite($GetWindowNamesAndHandles[$x] & @LF)
Next


Func GetWindowsFromEXE($exe_PID)
    Local $ListAll = ''
    Local $exe_WinList = WinList()
    For $i = 1 To $exe_WinList[0][0]
        $exe_WinPID = WinGetProcess($exe_WinList[$i][0])
        If $exe_PID == $exe_WinPID Then
            $ListAll = $ListAll & 'EXE Window Name = ' & $exe_WinList[$i][0] & '   |   ' & 'Handle of Window EXE = ' & $exe_WinList[$i][1] & Chr(01)
        EndIf
    Next
    Return StringSplit(StringTrimRight($ListAll, 1), Chr(01))
EndFunc

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

so did you manage to get this thing running Biohazard? I am wanting to do the same thing because sometimes when I unmount my USB drive, explorer.exe still has a handle on the root of the drive, and I get the "cannot remove hardware/still in use/close open programs and try again" error. It is almost always explorer.exe that is the culprit and I either use sysinternals to close the program or (before I found sysinternals) i used to just close explorer.exe manually with the task manager.

I don't want to use "force dismount" coz there might actually be something other than explorer.exe using the drive.

Anyway, yeah that's my story and I'd like to know if you got this script working coz it would be a good solution.


Eagles may soar, but weasels don't get sucked into jet engines.

Share this post


Link to post
Share on other sites

so did you manage to get this thing running Biohazard? I am wanting to do the same thing because sometimes when I unmount my USB drive, explorer.exe still has a handle on the root of the drive, and I get the "cannot remove hardware/still in use/close open programs and try again" error. It is almost always explorer.exe that is the culprit and I either use sysinternals to close the program or (before I found sysinternals) i used to just close explorer.exe manually with the task manager.

I don't want to use "force dismount" coz there might actually be something other than explorer.exe using the drive.

Anyway, yeah that's my story and I'd like to know if you got this script working coz it would be a good solution.

Last Seen: 3rd January 2007 - 12:43 AM

<_<

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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  
Followers 0