Iraj 1 Posted January 7, 2022 Share Posted January 7, 2022 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 post Share on other sites
Musashi 738 Posted January 7, 2022 Share Posted January 7, 2022 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. "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 post Share on other sites
Iraj 1 Posted January 7, 2022 Author Share Posted January 7, 2022 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 post Share on other sites
Solution Luke94 37 Posted January 7, 2022 Solution Share Posted January 7, 2022 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 post Share on other sites
Iraj 1 Posted January 7, 2022 Author Share Posted January 7, 2022 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 post Share on other sites
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now