Page 1 of 2

WUA error: No such file or directory

Published: October 10, 2022 - 3:53 PM
by t.heroult
Good morning

For the past few days, I've noticed the following error on a number of Windows 10 systems when scanning for Windows Update:

Code: Select all

Ensure wuauserv Auto Update option is disabled
Scanning with windows updates rules:
{
 "direct_download": false,
 "default_allow": false,
 "include_potentially_superseded_updates": false,
 "filter": "Type='Software' or Type='Driver'",
 "download_scheduling": "5d",
 "install_scheduling": "24h",
 "install_delay": "1d",
 "postboot_delay": "10m"
}
Looking for updates with filter: Type='Software' or Type='Driver'
   Connecting to local update searcher using offline wsusscn2 file...
   Offline Update searcher ready...
Waiting for WUA search to complete
WUA Search completed !
Done searching
re-enabling wuauserv previous state: 2
[Errno 2] No such file or directory: 'C:\\WINDOWS\\TEMP\\gen_py\\3.8\\B596CC9F-56E5-419E-A622-E01BB457431Ex0x2x0\\ISearchResult.py.4580.temp'
Traceback (most recent call last):
  File "C:\Program Files (x86)\wapt\lib\site-packages\win32com\client\gencache.py", line 233, in GetModuleForCLSID
    __import__(sub_mod_name)
ModuleNotFoundError: No module named 'win32com.gen_py.B596CC9F-56E5-419E-A622-E01BB457431Ex0x2x0.ISearchResult'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\wapt\waptservice\service.py", line 1894, in run
    self.running_task.run()
  File "C:\Program Files (x86)\wapt\waptservice\waptservice_common.py", line 699, in run
    self._run()
  File "C:\Program Files (x86)\wapt\waptservice\enterprise.py", line 232, in _run
    self.result = wua.scan_updates_status(self.force)
  File "C:\Program Files (x86)\wapt\waptwua\client.py", line 919, in scan_updates_status
    for update in self.updates():
  File "C:\Program Files (x86)\wapt\waptwua\client.py", line 854, in updates
    search_result = self.update_searcher().EndSearch(search_job)
  File "C:\WINDOWS\TEMP\gen_py\3.8\B596CC9F-56E5-419E-A622-E01BB457431Ex0x2x0\IUpdateSearcher3.py", line 48, in EndSearch
  File "C:\Program Files (x86)\wapt\lib\site-packages\win32com\client\__init__.py", line 96, in Dispatch
    return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, clsctx=clsctx)
  File "C:\Program Files (x86)\wapt\lib\site-packages\win32com\client\__init__.py", line 37, in __WrapDispatch
    klass = gencache.GetClassForCLSID(resultCLSID)
  File "C:\Program Files (x86)\wapt\lib\site-packages\win32com\client\gencache.py", line 180, in GetClassForCLSID
    mod = GetModuleForCLSID(clsid)
  File "C:\Program Files (x86)\wapt\lib\site-packages\win32com\client\gencache.py", line 241, in GetModuleForCLSID
    makepy.GenerateChildFromTypeLibSpec(sub_mod, info)
  File "C:\Program Files (x86)\wapt\lib\site-packages\win32com\client\makepy.py", line 319, in GenerateChildFromTypeLibSpec
    gen.generate_child(child, dir_path_name)
  File "C:\Program Files (x86)\wapt\lib\site-packages\win32com\client\genpy.py", line 1049, in generate_child
    self.file = self.open_writer(out_name)
  File "C:\Program Files (x86)\wapt\lib\site-packages\win32com\client\genpy.py", line 786, in open_writer
    return open(temp_filename, "wt", encoding=encoding)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\WINDOWS\\TEMP\\gen_py\\3.8\\B596CC9F-56E5-419E-A622-E01BB457431Ex0x2x0\\ISearchResult.py.4580.temp'

2 : No such file or directory
Traceback (most recent call last):
  File "C:\Program Files (x86)\wapt\lib\site-packages\win32com\client\gencache.py", line 233, in GetModuleForCLSID
    __import__(sub_mod_name)
ModuleNotFoundError: No module named 'win32com.gen_py.B596CC9F-56E5-419E-A622-E01BB457431Ex0x2x0.ISearchResult'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\wapt\waptservice\service.py", line 1894, in run
    self.running_task.run()
  File "C:\Program Files (x86)\wapt\waptservice\waptservice_common.py", line 699, in run
    self._run()
  File "C:\Program Files (x86)\wapt\waptservice\enterprise.py", line 232, in _run
    self.result = wua.scan_updates_status(self.force)
  File "C:\Program Files (x86)\wapt\waptwua\client.py", line 919, in scan_updates_status
    for update in self.updates():
  File "C:\Program Files (x86)\wapt\waptwua\client.py", line 854, in updates
    search_result = self.update_searcher().EndSearch(search_job)
  File "C:\WINDOWS\TEMP\gen_py\3.8\B596CC9F-56E5-419E-A622-E01BB457431Ex0x2x0\IUpdateSearcher3.py", line 48, in EndSearch
  File "C:\Program Files (x86)\wapt\lib\site-packages\win32com\client\__init__.py", line 96, in Dispatch
    return __WrapDispatch(dispatch, userName, resultCLSID, typeinfo, clsctx=clsctx)
  File "C:\Program Files (x86)\wapt\lib\site-packages\win32com\client\__init__.py", line 37, in __WrapDispatch
    klass = gencache.GetClassForCLSID(resultCLSID)
  File "C:\Program Files (x86)\wapt\lib\site-packages\win32com\client\gencache.py", line 180, in GetClassForCLSID
    mod = GetModuleForCLSID(clsid)
  File "C:\Program Files (x86)\wapt\lib\site-packages\win32com\client\gencache.py", line 241, in GetModuleForCLSID
    makepy.GenerateChildFromTypeLibSpec(sub_mod, info)
  File "C:\Program Files (x86)\wapt\lib\site-packages\win32com\client\makepy.py", line 319, in GenerateChildFromTypeLibSpec
    gen.generate_child(child, dir_path_name)
  File "C:\Program Files (x86)\wapt\lib\site-packages\win32com\client\genpy.py", line 1049, in generate_child
    self.file = self.open_writer(out_name)
  File "C:\Program Files (x86)\wapt\lib\site-packages\win32com\client\genpy.py", line 786, in open_writer
    return open(temp_filename, "wt", encoding=encoding)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\WINDOWS\\TEMP\\gen_py\\3.8\\B596CC9F-56E5-419E-A622-E01BB457431Ex0x2x0\\ISearchResult.py.4580.temp'
The folder C:\Windows\temp\gen_py\3.8 is indeed present...

If you have any ideas, I'm all ears.

Sincerely,
Tom

Re: WUA error: No such file or directory

Published: October 10, 2022 - 4:47 PM
by dcardon
Hi Tom,

it's been a while since we last heard about gencache.py... These are dynamically generated bindings to Windows COM objects, specifically the Windows Update object. It's not the prettiest part of Python on Windows.

I'll check with my colleagues to see if we can pre-generate these bindings during the agent installation/update. That would prevent it from trying to create them in TEMP. I think the antivirus is probably surprised by the presence of these files.

I'll keep you posted. In the meantime, could you check in your antivirus console to see if it hasn't deleted the files in question on the fly?

Best regards,

Denis

Re: WUA error: No such file or directory

Published: October 11, 2022 - 09:28
by t.heroult
Hi Denis

, OK, I see the kind of problem you're having, it's a real pain...
Well, I just checked the console (SentinelOne) and I don't see any reports corresponding to this problem on any of the affected machines.

Sorry, but it seems like a dead end. :(

In any case, I'm available to run some tests if you'd like.

Best regards,
Tom

Re: WUA error: No such file or directory

Published: May 15, 2023 - 11:28
by t.heroult
Hello,

I'm still experiencing this problem regularly.
Currently, it affects 5 Windows 10 Pro machines.

Re: WUA error: No such file or directory

Published: May 16, 2023 - 3:08 PM
by sfonteneau
in this type of case the file

Code: Select all

C:\WINDOWS\TEMP\gen_py\
is present on the machine (without rebooting the wapt service)

Re: WUA error: No such file or directory

Published: May 22, 2023 - 2:11 PM
by t.heroult
Indeed, the folder is there.
If I delete it and run a scan, it's recreated and the bug occurs again.

Re: WUA error: No such file or directory

Published: May 22, 2023 - 4:38 PM
by sfonteneau
and the file

Code: Select all

C:\WINDOWS\TEMP\gen_py\3.8\B596CC9F-56E5-419E-A622-E01BB457431Ex0x2x0\ISearchResult.py
Is he present?

Re: WUA error: No such file or directory

Published: May 23, 2023 - 09:36
by t.heroult
Negative.

I only have 2 files in the 3.8 folder:
- __init__.py
- dicts.dat

Re: WUA error: No such file or directory

Published: May 23, 2023 - 09:59
by sfonteneau
The code that generates the file is as follows:

Code: Select all

C:\Windows\System32>waptpython
Python 3.8.16 (default, Mar  1 2023, 11:11:02) [MSC v.1929 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32com.client
>>> win32com.client.gencache.EnsureDispatch("Microsoft.Update.Session")
Could you try launching it in a Windows terminal?

In the end, you should normally have the following file:

Code: Select all

type %tmp%\gen_py\3.8\B596CC9F-56E5-419E-A622-E01BB457431Ex0x2x0\__init__.py

Re: WUA error: No such file or directory

Published: May 23, 2023 - 2:09 PM
by t.heroult
Great, it worked on both machines.

Thank you!