When deploying an application, it may be necessary for some processes to be closed. This is the case when installing new software or updating. For example, if you are updating Firefox, the browser will need to be closed before starting the update. In other cases, the update may close the application by itself without warning the user. This can cause data loss and the user experience is poor in all cases. Fortunately, it is possible to check whether a process is running or not without having to use a script for each update. We will use a global condition to check if the application is running. For this example, I will take the Teams application for which I need to check that it is closed. I want to disable autostart as described in this post.
Create a global condition to check if the application is running
Go to « Software Library« , expand « Application Management » and click on « Global Conditions« . Then click on Create a global condition.
Type the name of the application (Teams). Select « Script » in the parameter type and « Boolean » in the data type. Then click on «Add a script.
Enter the following command line:
[bool] (Get-Process teams -ea 0)
Then click OK and then OK again. Your global condition is now created. To use it, go to your application, tab « Specifications » and click on « Add« . In the first drop-down list, select « Custom » and in « Conditions« , choose your global condition. 3 new drop down lists appear, change the value to False.
This way, the deployment will only start if the application is closed. The reverse is also possible, by choosing True.
Pingback: How to easily detect the version of Windows 10