BUG: wuauserv state not verified if not English OS

BUG: wuauserv state not verified if not English OS

Postby georgeman » 11.08.2017, 19:22

Hi! I recently started using wsusoffline and while implementing, I discovered a bug.

In the :WaitService section of client's DoUpdate.cmd, there is this line:

Code: Select all
for /F "tokens=4" %%j in ('%SystemRoot%\System32\sc.exe query %1 2^>nul ^| %SystemRoot%\System32\find.exe /I "STAT"') do (


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.

Best regards.
georgeman
 

Re: BUG: wuauserv state not verified if not English OS

Postby Dalai » 11.08.2017, 22:36

Could you please post the complete ouput of
Code: Select all
sc query wuauserv
so that we can actually see what sc.exe prints on Spanish Windows?

BTW: On German Windows the output of sc.exe is English, so it DOES work on non-English Windows (but not on non-English sc.exe).

Regards
Dalai
Dalai
 
Posts: 1041
Joined: 12.07.2016, 21:00

Re: BUG: wuauserv state not verified if not English OS

Postby georgeman » 11.08.2017, 22:39

Code: Select all
NOMBRE_SERVICIO: wuauserv
        TIPO               : 20  WIN32_SHARE_PROCESS
        ESTADO             : 4  RUNNING
                                (STOPPABLE, NOT_PAUSABLE, ACCEPTS_PRESHUTDOWN)
        CÓD_SALIDA_WIN32   : 0  (0x0)
        CÓD_SALIDA_SERVICIO: 0  (0x0)
        PUNTO_COMPROB.     : 0x0
        INDICACIÓN_INICIO  : 0x0



As you can see, the actual state is in English ("RUNNING"), but the line needs to be filtered in Spanish in this case ("ESTADO").

I have no idea about other languages. This is from Win7 x64 Spanish.

Best regards!
georgeman
 

Re: BUG: wuauserv state not verified if not English OS

Postby Dalai » 12.08.2017, 01:41

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* :evil:

@WSUSUpdateAdmin
I 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:
Code: Select all
set wuauserv_state_en-us=STATE
set wuauserv_state_es-es=ESTADO
set wuauserv_state_de-de=STATE
(and so on)
And in DoUpdate.cmd call this batch, and get the variable's contents using the locale it already determined, something like this:
Code: Select all
sc.exe query wuauserv | call %SystemRoot%\System32\find.exe /I "%wuauserv_state_%locale%%"
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.

Regards
Dalai
Dalai
 
Posts: 1041
Joined: 12.07.2016, 21:00

Re: BUG: wuauserv state not verified if not English OS

Postby georgeman » 14.08.2017, 19:52

The position is always the same (two lines below the service name), and the state itself looks like it's always in English.

Can we just filter it this way?

Best regards
georgeman
 

Re: BUG: wuauserv state not verified if not English OS

Postby Dalai » 14.08.2017, 22:36

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.

Regards
Dalai
Dalai
 
Posts: 1041
Joined: 12.07.2016, 21:00

Re: BUG: wuauserv state not verified if not English OS

Postby aker » 15.08.2017, 08:47

Could I get access to a copy of your (Spanish) C:\Windows\System32\es-es\sc.exe.mui & C:\Windows\System32\sc.exe?
Wer Rechtschreibfehler findet, darf sie behalten oder an den Meistbietenden versteigern. / Everybody finding a misspelling is allowed to keep or sell it.
aker

WSUS Offline Update „Community Edition“
https://gitlab.com/wsusoffline/wsusoffline/-/releases
aker
 
Posts: 3999
Joined: 02.03.2011, 15:32


Re: BUG: wuauserv state not verified if not English OS

Postby aker » 17.08.2017, 09:41

In my opinoin, it would be too difficult to filter out all languages "STATE"-name.

@WSUSUpdateAdmin
Could we change this to WMI (Win32_Service)?
WMI_Win32_Service.png
(11.3 KiB) Not downloaded yet
Wer Rechtschreibfehler findet, darf sie behalten oder an den Meistbietenden versteigern. / Everybody finding a misspelling is allowed to keep or sell it.
aker

WSUS Offline Update „Community Edition“
https://gitlab.com/wsusoffline/wsusoffline/-/releases
aker
 
Posts: 3999
Joined: 02.03.2011, 15:32

Re: BUG: wuauserv state not verified if not English OS

Postby WSUSUpdateAdmin » 28.09.2017, 13:21

Hi.

Many thanks and sorry for delay!
:arrow: http://trac.wsusoffline.net/browser/trunk (r897).

Cheers,
Torsten
WSUSUpdateAdmin
Administrator
 
Posts: 2245
Joined: 07.07.2009, 14:38


Return to Anregungen / Suggestions

Who is online

Users browsing this forum: No registered users and 27 guests