Tag Archives: Close Process

Close the application process on SUT using Eggplant

It is little tricky to talk to the file system or the task manager in the most reliable ways using eggplant.
Below is the code to close the process using command prompt with Eggplant instead of using the Task manager images.

function CloseApplicationProcess
try
TypeText windowsKey
TypeText controlKey ,"r"
TypeText "Cmd.exe"
TypeText enterKey
wait 1
TypeText "taskkill /FI " && quote &"Imagename eq test.exe" & quote & " -f"
TypeText enterKey
wait 1
TypeText "exit"
TypeText enterKey
return true
Catch anException
tracescreen on
put the exception's location into excepLoc
replace return in excepLoc with ", "
log anException & " | " & excepLoc & " | " & " Function : CloseApplication"
return false
end try
end CloseApplicationProcess

you can do a lot more by interacting with the command prompt, like dealing with the file system, running the batch files, restarting the services etc.
Whatever you could do using command prompt on a machine, can be done this way using Eggplant on the SUT directly.