Jump to content

Process not getting killed via ProcessClose()


Go to solution Solved by Luke94,

Recommended Posts

Posted

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.

Posted
  On 1/7/2022 at 8:16 AM, Iraj said:

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

Expand  

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

Posted
  On 1/7/2022 at 8:27 AM, Musashi said:

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

Expand  

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

Can you assist?

  • Solution
Posted
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.

Posted
  On 1/7/2022 at 9:31 AM, 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.

Expand  

thanks. Working!

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
  • Recently Browsing   0 members

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