Your error isn't with your batch file it is with your server.
https://technet.microsoft.com/en-us/library/cc735059%28v=ws.10%29.aspx[
^]
If you look at the documentation it even says
Quote:
The event log message is informational regarding performance counter status. The issue will be corrected by the system; you do not have to take any action.
That error message is usually due to your server maxing out on resources. So what appears to be happening is that your batch script is running at the same time your server is under load. When things slow down for your server, it is usually when it is able to resolve this issue.
As I see it you have the following options
1) Restart the service at a time where you can afford down time
2) Don't restart the service and re-think what your batch script is doing/when it is running and run it at a different time/in a different medium/language.
3) Increase available resources that your server has in order to prevent this error from happening. This could also include load balancing your server to accommodate extra load.
One thing to note though, restarting the w3svc process may not permanently fix your problem...it is probably only going to put off only to happen again later on down the road. The true fix here is to evaluate your hardware, see what is hogging up resources on your server and go from there.