WinBatch® Technical Support Forum

All Things WinBatch => WinBatch => Topic started by: siocnarf on March 29, 2022, 07:42:43 AM

Title: Finding and killing a process
Post by: siocnarf on March 29, 2022, 07:42:43 AM
Hi,

How would I test if the process javaw is in memory then killing it?

Thanks,
Title: Re: Finding and killing a process
Post by: td on March 29, 2022, 07:55:45 AM
There are multiple ways. Check out the AppExist function:

https://docs.winbatch.com/mergedProjects/WindowsInterfaceLanguage/html/WILAK_A__005.htm (https://docs.winbatch.com/mergedProjects/WindowsInterfaceLanguage/html/WILAK_A__005.htm)

Another approach is to use the Process Extender's tListProc function:

https://docs.winbatch.com/mergedProjects/Process/Process/PROCESS_T__002.htm (https://docs.winbatch.com/mergedProjects/Process/Process/PROCESS_T__002.htm)

There are other approaches as well.

Title: Re: Finding and killing a process
Post by: siocnarf on March 29, 2022, 08:10:40 AM
Hi,

And what would be the correct way to kill that process?

Thanks,
Title: Re: Finding and killing a process
Post by: td on March 29, 2022, 08:38:39 AM
If you look in the Consolidated WIL Help file on your computer in the table of contents under "Windows Interface Language Reference -> Functions -> By Type -> Process Control",  you will notice the function "TerminateApp".  Assuming you have the correct process name or window name and your process is a regular Windows application, it should be suggestive...
Title: Re: Finding and killing a process
Post by: td on March 29, 2022, 01:13:00 PM
Also, if you need to kill the process without using the process name The Process Extender has the "tKillProc" function. There are several other approaches including using WIL CLR hosting capabilities and the "System.Diagnostics.Process" class.