Jump to content

Kill Child Process if Parent Process is forced to close


fRequEnCy
 Share

Recommended Posts

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
Link to comment
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.

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...