Invoke PowerShell to kill excel in VM environment

Hi,
if i uses invoke power shell to task kill excel.exe will that have implication to other background running excel on other processor?

As in if there are two robot running in the background and one foreground and there is an invoke power shell activity to taskkill /F /IM excel.exe, will this command also execute those that are not under this processes been killed by this command?

Thanks

Yes, if you use the “Invoke Power Shell” activity to forcefully terminate the Excel process by running the command taskkill /F /IM excel.exe , it will terminate all running instances of Excel on the machine where the PowerShell script is executed. This command is not limited to killing Excel instances associated with a specific process or user; it will terminate all Excel processes matching the specified image name.

Cheers!

is there other way?
since Kill Process is unable to kill excel that is still running in the background as VM syncing is too slow even with delay also don’t help.

we assume that the session / non-session ones are meant

when only the own session processes are to kill then filter it on the session id similar to:

Close Workbook: Instead of killing the Excel process, you can try closing the specific workbooks that are causing issues. Use the “Excel Application Scope” activity to open the workbook, perform any necessary operations, and then use the “Close Workbook” activity to close it. This approach may be more controlled and have less impact on other running instances of Excel.

VBA Macro: You can use the “Invoke VBA” activity within an “Excel Application Scope” to execute a VBA macro that closes specific workbooks or performs other cleanup actions. VBA macros can provide more flexibility and control over Excel operations.

PowerShell with Excel COM Object: Instead of using the “taskkill” PowerShell command, you can use PowerShell with the Excel COM object to interact with Excel and close specific workbooks or instances. This approach allows for more targeted control and can be more graceful than forcefully terminating processes.

Check for Open Workbooks: Before attempting to close or kill Excel, you can use PowerShell or VBA to check if the workbooks that need to be closed are already open. If they are open, perform the necessary actions to save and close them gracefully.

Increase Timeout and Retry: If VM synchronization is causing delays, you can increase the timeout in the “Kill Process” activity and add retries to ensure that the activity has enough time to terminate the Excel process.

Cheers!!

not complete clear, but in a loop using the HasExited flag can help for sync on it

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.