Jump to content

Process not getting killed via ProcessClose()


Iraj
 Share

Go to solution Solved by Luke94,

Recommended Posts

Hi team,

Greetings!

 

I need some assistance in closing Y process once X process is closed.

I have written below script :

If ProcessExists("notepad.exe") Then
   ShellExecute("C:\Progra~1\Work\dll\bin\player.exe","args")
Else
   ProcessClose("player.exe")
EndIf

The problem is it is not going to Else part, that's why the process is not getting closing.

Need some guidance. Thank you.

Link to comment
Share on other sites

7 minutes ago, Iraj said:

The problem is it is not going to Else part, that's why the process is not getting closing.

As long as the process "notepad.exe" still exists, the Else part cannot be executed either.

Musashi-C64.png

"In the beginning the Universe was created. This has made a lot of people very angry and been widely regarded as a bad move."

Link to comment
Share on other sites

9 minutes ago, Musashi said:

As long as the process "notepad.exe" still exists, the Else part cannot be executed either.

When I am closing notepad manually, the player.exe should be closing. I need that.

Can you assist?

Link to comment
Share on other sites

  • Solution
If ProcessExists('notepad.exe') Then
    ShellExecute('calc.exe')
    Do
        Sleep(10)
    Until ProcessExists('notepad.exe') = 0
    ProcessClose('calc.exe')
EndIf

This example uses Notepad and Calculator. Is this what you're looking for?

Run Notepad and then run the script.

When you close Notepad the Calculator will also be closed. You could also wrap this in a While loop and check if the calculator process exists after checking if Notepad exists. This would make it so whenever Notepad is open, if the Calculator isn't open then it'll open it.

Link to comment
Share on other sites

2 hours ago, Luke94 said:
If ProcessExists('notepad.exe') Then
    ShellExecute('calc.exe')
    Do
        Sleep(10)
    Until ProcessExists('notepad.exe') = 0
    ProcessClose('calc.exe')
EndIf

This example uses Notepad and Calculator. Is this what you're looking for?

Run Notepad and then run the script.

When you close Notepad the Calculator will also be closed. You could also wrap this in a While loop and check if the calculator process exists after checking if Notepad exists. This would make it so whenever Notepad is open, if the Calculator isn't open then it'll open it.

thanks. Working!

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...