You might consider using Windows Scripting to detect the running process and terminating it.
The following will terminate any running Windows Calculator instances (This requires that Windows Scriting be installed on the computer)
terminateProcess('CALC.EXE')
FUNCTION terminateProcess(lcProcess)
lcComputer = "."
loWMIService = Getobject("winmgmts:" ;
+ "{impersonationLevel=impersonate}!\\" + lcComputer + "\root\cimv2")
colProcessList = loWMIService.ExecQuery ;
("Select * from Win32_Process")
For Each loProcess In colProcessList
IF UPPER(loProcess.name) = lcProcess
loProcess.terminate()
endif
Next
>I try to close another Application eg. Ms Calculator by using API call. I try the following code but it does not work.
>
>
>
>DECLARE INTEGER FindWindow ;
> IN WIN32API STRING cNull,STRING cWinName
>
>
>DECLARE INTEGER SendMessage IN user32;
> INTEGER hWnd,;
> INTEGER Msg,;
> INTEGER wParam,;
> INTEGER lParam
>
>
>mWinHandle = FindWindow(0,'Calculator')
>IF mWinHandle > 0
> SendMessage(mWinHandle,10,0,0)
>ELSE
> MESSAGEBOX(mWinHandle)
>ENDIF