Sometimes when we try to install patches in SharePoint environment we face the error stating
An error occurred while running detection.
This is due to a reason that SharePoint couldn’t recognize whether the version of the patch that is going to be installed is valid for your environment or not.
Its solution is very simple. On every server that you are facing this issue, run the following command in SharePoint Management Shell:
After this when you try to run the CU it would run successfully.