Sign in to follow this  
Followers 0
fRequEnCy

Kill Child Process if Parent Process is forced to close

6 posts in this topic

#1 ·  Posted (edited)

I have a problem and hoping someone has a solution. I have a script that runs another app. Now when the app closes then the script closes just fine using ProcessWaitClose().

Example:

$PID = Run("app.exe")

ProcessWaitClose($PID)

Exit

But what I'm wanting is a way to close the app if the script process is forced to close like in Task Manager. Now I've successfully done this using another script (kill_child) making sure everything closes cleanly. Script kill_child is called and makes sure everything is closed the way I'm wanting.

Example:
$PID = Run("app.exe")

run("kill_child.exe")

ProcessWaitClose($PID)

Exit

I've played with OnAutoItExit() and it works somewhat that if the script is closed then the app is closed. But OnAutoItExit() doesn't work when process of script is forced to close. Any ideas other than what I'm currently doing to accomplish this with just one script?

Edited by fRequEnCy

Share this post


Link to post
Share on other sites



bump and changed title for better understanding. Any help would be appreciated.

Share this post


Link to post
Share on other sites

bump and changed title for better understanding. Any help would be appreciated.

Great example from SmOke_N :)

Share this post


Link to post
Share on other sites

Thanks for the example but didn't understand how to close the child window if parent window is forced to close.

Share this post


Link to post
Share on other sites

Thanks for the example but didn't understand how to close the child window if parent window is forced to close.

You can close the child window in next program starting.

Share this post


Link to post
Share on other sites

You can close the child window in next program starting.

True but then I have to rely on running the next program just to do it. I'll stick with my kill_child script for the time being since it exits it cleanly. But there's gotta be a way to do this. Maybe even capture the process close and force a process tree close or something. I just wanna have to use 1 file instead of the 2. No big deal since the files are small but makes it clean for the user. Maybe can do a FileInstall and install my kill_child script with my wrapper and have the kill_child script delete itself after cleanup.

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