The problem is that the output of sc.exe is language dependant. My OS is in Spanish, so I had to change "STAT" to "ESTADO" for example, otherwise it would hang for 3 minutes everytime it wants to stop wuauserv.

To be sincere, I have no idea how to make it language independent, but still I wanted to let you know.

MS really is a pain in the ass when it comes to localization! Not only do they translate Windows Firewall Rules so they can't be managed/scripted by netsh in a meaningful way, no, they even translate parameters to command line programs (takeown.exe)! *argh*

@WSUSUpdateAdminI have an idea how such situations can be handled, although this wouldn't work without knowing the translation of every term that is fed into find(str).exe. Use some helper batch that contains the translated strings for such situations. Something like this:

assuming %locale% contains the locale. Furthermore there should be some kind of default string that is used when no localized string is set.

I also thought about getting the required string directly from the MUI files (sc.exe.mui) but that doesn't contain any resource strings on my German system, so I'm not sure this is the case on other systems.

georgeman wrote:The position is always the same (two lines below the service name)

Maybe, and I thought about this as well. But can you guarantee this for Russian, Arabic or CJK Windows systems? Also, this doesn't consider the situation when MS changes something in sc.exe anytime in the future, maybe they change the output's order - this would break the for loop completely.

and the state itself looks like it's always in English.

Yes, but the state is exactly what the for loop is supposed to extract.