Compartir: Restablecer Windows Update

Comparta sus sugerencias o problemas relacionados con la consola WAPT o el agente WAPT aquí
Reglas del foro
Reglas del foro de la comunidad
* Soporte en inglés en www.reddit.com/r/wapt
* El soporte de la comunidad en francés está disponible en este foro
* Por favor, anteponga [RESUELTO] al título del tema si está resuelto.
* Por favor, no edite un tema que esté etiquetado como [RESUELTO]. Abra un nuevo tema haciendo referencia al anterior.
* Especifique la versión de WAPT instalada, la versión completa y el número de compilación (2.2.1.11957 / 2.2.2.12337 / etc.), así como la edición Enterprise/Discovery.
* Las versiones 1.8.2 y anteriores ya no son compatibles. Las únicas preguntas aceptadas sobre la versión 1.8.2 están relacionadas con la actualización a una versión compatible (2.1, 2.2, etc.).
* Especifique el sistema operativo del servidor (Linux/Windows) y la versión (Debian Buster/Bullseye - CentOS 7 - Windows Server 2012/2016/2019).
* Especifique el sistema operativo de la máquina de administración/creación de paquetes y de la máquina con el agente problemático, si corresponde (Windows 7/10/11/Debian 11/etc.).
* Evite hacer varias preguntas al abrir un tema, ya que podría ser ignorado. Si hay varios temas, ábralos por separado, preferiblemente uno tras otro y no todos a la vez (es decir, no sature el foro con spam).
* Incluya fragmentos de código, capturas de pantalla y otras imágenes directamente en la publicación. Los enlaces a Pastebin, Bitly y otros sitios de terceros serán eliminados sistemáticamente.
* Como en cualquier foro comunitario, el soporte es proporcionado voluntariamente por los miembros. Si necesita soporte comercial, puede comunicarse con el departamento de ventas de Tranquil IT al 02.40.97.57.55.
Bloqueado
Avatar de usuario
t.heroult
Mensajes: 304
Inscripción: 8 de diciembre de 2020 - 10:13 a. m.

9 de junio de 2022 - 14:10

Hola a todos.
Estoy compartiendo con ustedes un pequeño paquete que desarrollé para solucionar bastantes problemas con WindowsUpdate.
De hecho, es una recopilación de las principales acciones conocidas para solucionar un error en WindowsUpdate.

Medidas adoptadas:
  • Limpieza de DNS
  • Purgas:
  • - Archivos "qmgr*.dat" en ALLUSERSPROFILE/Datos de aplicación/Microsoft/Red/Descargador
  • - Archivos "qmgr*.dat" en ALLUSERSPROFILE/Microsoft/Network/Downloader
  • - Todos los archivos en WINDIR/Logs/WindowsUpdate
  • Eliminaciones de carpetas (se reconstruirán cuando se inicie el servicio Windows Update):
  • - WINDIR/Distribución de software
  • - SYSTEM32/Catroot2
  • Eliminación de clave de registro:
  • - HKLM\SOFTWARE\Políticas\Microsoft\Windows\WindowsUpdate
  • - HKLM\SOFTWARE\Microsoft\Windows\Versión actual\Políticas\WindowsUpdate
  • GPUPDATE (a nivel de máquina)
  • Restablecer el servicio "bits"
  • Restablecer el servicio “Windows Update”
  • Volver a registrar algunas DLL
  • Reinicio de Winsock
  • Configurar el inicio del servicio
  • Reiniciar los servicios si es necesario
  • Si Waptwua está activo, deshabilite el servicio Windows Update
Y aquí está el código:

Código: Seleccionar todo

def install():
    print("Arrêt des services :")
    Stop_Service_if_needed('bits',"- Background Intelligent Transfer Service (bits).")
    Stop_Service_if_needed('wuauserv',"- Windows Update (wuauserv).")
    Stop_Service_if_needed('appidsvc',"- Application Identity (appidsvc).")
    Stop_Service_if_needed('cryptsvc',"- Cryptographic Services (cryptsvc).")

    print("Flush DNS")
    run("Ipconfig /flushdns")
    dossier = makepath(os.environ.get('ALLUSERSPROFILE'),'Application Data','Microsoft','Network','Downloader')
    if isdir(dossier):
        fichiers = find_all_files(dossier,include_patterns='qmgr*.dat')
        print('Purge des fichiers "qmgr*.dat" de ' + dossier)
        for fichier in fichiers:
            remove_file(fichier)
            print("Suppression de : " + fichier)

    dossier = makepath(os.environ.get('ALLUSERSPROFILE'),'Microsoft','Network','Downloader')
    if isdir(dossier):
        fichiers = find_all_files(dossier,include_patterns='qmgr*.dat')
        print('Purge des fichiers "qmgr*.dat" de ' + dossier)
        for fichier in fichiers:
            remove_file(fichier)
            print("Suppression de : " + fichier)

    dossier = makepath(os.environ.get('WINDIR'),'Logs','WindowsUpdate')
    if isdir(dossier):
        fichiers = find_all_files(dossier)
        print('Purge du dossier ' + dossier)
        for fichier in fichiers:
            remove_file(fichier)
            print("Suppression de : " + fichier)

    f_pending_xml = makepath(os.environ.get('WINDIR'),'winsxs','pending.xml')
    if isfile(f_pending_xml + '.bak'):
        remove_file(f_pending_xml + '.bak')
    if isfile(f_pending_xml):
        print("sauvegarde de " + f_pending_xml)
        os.rename(f_pending_xml,f_pending_xml + '.bak')

    dossier = makepath(os.environ.get('WINDIR'),'SoftwareDistribution')
    if isdir(dossier):
        print("Suppression de " + dossier)
        remove_tree(dossier)

    dossier = makepath(system32,'Catroot2')
    if isdir(dossier):
        print("Suppression de " + dossier)
        remove_tree(dossier)

    if reg_key_exists(HKEY_LOCAL_MACHINE,'SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate'):
        print('Purge de la clé de registe : HKLM\SOFTWARE\Policies\Microsoft\Windows\WindowsUpdate')
        registry_deletekey(HKEY_LOCAL_MACHINE,'SOFTWARE\Policies\Microsoft\Windows','WindowsUpdate')
    if reg_key_exists(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\WindowsUpdate'):
        print('Purge de la clé de registe : HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\WindowsUpdate')
        registry_deletekey(HKEY_LOCAL_MACHINE,'SOFTWARE\Microsoft\Windows\CurrentVersion\Policies','WindowsUpdate')

    print("GPUPDATE (ordinateur)")
    run('gpupdate /force /target:computer')

    print('Reset du service "bits"')
    run('sc.exe sdset bits D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)')
    print('Reset du service "Windows Update"')
    run('sc.exe sdset wuauserv D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;AU)(A;;CCLCSWRPWPDTLOCRRC;;;PU)')

    lst_dlls = ['atl.dll','urlmon.dll','mshtml.dll','shdocvw.dll','browseui.dll','jscript.dll','vbscript.dll','scrrun.dll','msxml.dll','msxml3.dll','msxml6.dll','actxprxy.dll','softpub.dll','wintrust.dll','dssenh.dll','rsaenh.dll','gpkcsp.dll','sccbase.dll','slbcsp.dll','cryptdlg.dll','oleaut32.dll','ole32.dll','shell32.dll','initpki.dll','wuapi.dll','wuaueng.dll','wuaueng1.dll','wucltui.dll','wups.dll','wups2.dll','wuweb.dll','qmgr.dll','qmgrprxy.dll','wucltux.dll','muweb.dll','wuwebv.dll','wudriver.dll']
    print("Ré-enregistrement de quelques dlls.")
    for f_dll in lst_dlls:
        fichier = makepath(system32,f_dll)
        run_notfatal('regsvr32.exe /s %s' % fichier)

    print("Réinitialisation du winsock.")
    run('netsh winsock reset')
    run('netsh winsock reset proxy')

    print("Configuration des services")
    run_notfatal('sc config wuauserv start= auto')
    run_notfatal('sc config bits start= auto ')
    run_notfatal('sc config DcomLaunch start= auto')


    print("Redémarrage des services selon leur propriété 'startup'")
    Start_Service_if_needed('bits',"- Background Intelligent Transfer Service (bits).")
    Start_Service_if_needed('wuauserv',"- Windows Update (wuauserv).")
    Start_Service_if_needed('appidsvc',"- Application Identity (appidsvc).")
    Start_Service_if_needed('cryptsvc',"- Cryptographic Services (cryptsvc).")

    # Si WAPTwua est actif sur la cible, alors désactivation et arrêt du service Windows Update
    if inifile_hassection(WAPT.config_filename,'waptwua'):
        waptwua_setting = inifile_readstring(WAPT.config_filename,'waptwua','enabled')
        if (waptwua_setting == 'True' or waptwua_setting == '1'):
            print("Waptwua est activé sur ce poste.")
            run_notfatal('sc config wuauserv start= disabled')
            Stop_Service_if_needed('wuauserv',"- Désactivation et arrêt du service Windows Update.")

    pass
    # put here what to do when package is installed on host
    # implicit context variables are WAPT, basedir, control, user, params, run

def Start_Service_if_needed(Service,DisplayInfo):
    if service_installed(Service):
        if not service_is_running(Service):
            key = reg_openkey_noredir(HKEY_LOCAL_MACHINE,'SYSTEM\CurrentControlSet\Services\%s' % (Service),KEY_READ)
            startup = reg_getvalue(key,'Start')
            if startup == '2':
                print(DisplayInfo)
                service_start(Service)

def Stop_Service_if_needed(Service,DisplayInfo):
    if service_installed(Service):
        if service_is_running(Service):
            print(DisplayInfo)
            service_stop(Service)
Atentamente,
Tomás
Servidor: WAPT Enterprise 2.6.1.17765 en Debian
Consolas: Windows 10 y 11
Infraestructura: Windows

¿Sabías que? ¡Cuando los peces loro experimentan la esmoltificación, su mecanismo de osmorregulación se invierte!
Avatar de usuario
erenodau
Mensajes: 28
Inscripción: 20 de febrero de 2019 - 10:42
Ubicación: Saint Sébastien sur Loire
Contacto :

9 de junio de 2022 - 16:46

Hola,

gracias por compartir, ¡parece muy interesante! ¡

Que tengas un buen día y hasta pronto!
Bloqueado