i’m currently struggling with a very basic problem. I want to build a generic workflow which closes/kills all apps which are defined by a string list, e.g. “excel.exe, word.exe”…
Killing those applications is quite straight-forward, however, as it is recommended by UiPath, it should be tried to close these softly first.
So I want to use the close application activity within a “for each” loop. This for each loop shall go through the list of defined “*.exe” and try to close them. Consequently, the selector of this activity has to be defined via a variable.
I was thinking about building a template where X gets replaced by the exe. name as described above.
However, the result is either very slow or does not work at all.
Does somebody have any advice for doing this?
Hello @Rahul_Unnikrishnan ,
thank you for your response. Yes, I know about this. As described above, I am already using this component. My questions refers to how I can make that more generic - or more specifically make the selector generic. So I want to input a list of *.exe strings and the workflow first tries to close them and then tries to kill the processes if required. The generic “killing” process is easy but I cant get a generic closing to work.
I dont want to create a selector for each application that I am using.
Then you can use Kill Process activity and pass the process name. For example if you want to close chrome , give process as. “chrome.exe”. You can get it from a list and pass the process name to this activity. Then it will close all.
@Rahul_Unnikrishnan Thank you.
Yes I already did this with the kill process activity, as I have described in the question above. My problem was that I want to do the same with the close application to ensure a soft closing first.
You can try by inspecting on 2 applications and check whether you can pass application name to the selector to close using Close Application activity. Just try for 2 application and check whether its working or not. If its working you can get the list and pass it.
maybe some title will there in the selector which you can make it dynamic.
Dim appsToClose() As String = {"winword", "excel", "notepad"}
For Each app As String In appsToClose
For Each p As Process In Process.GetProcessesByName(app)
Console.WriteLine("Soft closing " + app)
p.CloseMainWindow()
p.Close()
Next
Next
Note that the soft closing only works if there is no unsaved data. Otherwise the Save-prompt will prevent the program from closing.