SharePoint Application Pools keep Stopping

If you are facing this problem where the application pools keep stopping .

1- Go to Start Menu -> administrative tools -> Group local Policy

2- Select User Rights Managements and make sure that the user accounts running these application pools are added to the policies "Log on as batch" and "log on as service"