Kill process (excel)

Any other ways to kill the excel process rather than using kill process activity

Help me with suggestions

You coulc attach the window and use a close application activity, though kill process is safe as long as you’ve saved the files you want to save.

I am facing some issues where the excel is opened in the background and not closed… When you look at the screen you couldn’t see the excel it is open in the background… The only way I could close it with manually going to task manager and ending the excel process…

In this process of closing excel… Kill process fails

Help me to overcome this sort of issues

1 Like

You could alternatively invoke a command prompt and use a type into activity to send a taskkill to Excel.

https://www.windows-commandline.com/taskkill-kill-process/

1 Like

Hi @Sweety_Girl

Please save this as a .bat file

taskkill /f /im excel.exe /fi “USERNAME eq %USERNAME%”
image

And use start process to call this .bat file

image

Regards
Roshan

Mark as a solution if found useful :slight_smile:

2 Likes

Keep in mind that this is similar to running a Kill Process activity in that it kills the Excel background process rather than closing the window as a user would.

Which one?

Hi @Sweety_Girl

using taskkill is like killing a process. The script i gave kills only for your session other session it wont be effected. I have used it in several places didnt got any issue you can try it out.

Regards
Roshan

Should we give the systems username in the place of USERNAME

Hi @Sweety_Girl

No you keep it like that only. what it dose is if you are on a server chrome in your session will be close while others wont face any issues :slight_smile:

Regards
Roshan

NB: Mark as solution if found useful :slight_smile:

In a server environment, Kill Process will cause an error if you don’t have admin rights. And, if you do have admin rights, it will kill the process for other users.

So, you could simply just set the ContinueOnError to “True”, so it skips over if it is unable to kill due to no admin rights.

Or, if you would like a a solution that only kills for the currently logged in user, then check out a workflow I made in the Component Marketplace: Kill Processes per User - RPA Component | UiPath Marketplace
It’s a little old and may need updates (ie like it might have Write Line instead of Log Message)

Hopefully, that sheds some light on your issue.

Regards

3 Likes

@Sweety_Girl, A simpler way is to use excel shortcuts.

so just use the send hotkey activity and one of the below shortcuts:

Alt + F4 to close Excel Or Ctrl + F4 to close the workbook.

I recommend Alt + F4 for your scenario.

Hi @SenzoD

Alt + F4 closes the application which is having focus we cannot ensure that excel is having focus right :slight_smile:

@unknownay, Sure :thinking:,

in that case she can execute VBA method something like this: workbooks("workbookname").close

https://docs.microsoft.com/en-us/office/vba/api/excel.workbook.close

@Sweety_Girl, this could be an option worth trying too: