A script to delete reg keys and then reset authorisation...?

Discussion in 'Update Services' started by Woody, Jun 27, 2005.

  1. Woody

    Woody Guest

    I was wondering if it would be possible to have a script of some sort that
    would delete the registry entries in

    'HKEY_local_machine>software>microsoft>windows>current version>windowsupdate
    (PingID, AccountDomainSid,SusClientSid' and then run wuauclt.exe
    /resetauthorization /detectnow .

    I have found that this is helping me get the clients show up in WSUS that
    were not showing before. I have done around 10 manually but i have over 100
    to do.

    Any such thing available to do thi and if so can someone point me in the
    right direction please

    Thanks in advance.
     
    Woody, Jun 27, 2005
    #1
    1. Advertisements

  2. Woody

    Lon Guest

    I'm working on a script that does this.
    I just started with it so I do not have it ready yet.
     
    Lon, Jun 27, 2005
    #2
    1. Advertisements

  3. Hi,

    You could e.g. use this VBScript (a .vbs file):

    '--------------------8<----------------------
    Set oShell = CreateObject("WScript.Shell")

    sRegKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate"

    On Error Resume Next
    ' Delete registry values
    oShell.RegDelete sRegKey & "\AccountDomainSid"
    oShell.RegDelete sRegKey & "\PingID"
    oShell.RegDelete sRegKey & "\SusClientId"

    ' Stop and start the Automatic updates service
    oShell.Run "%SystemRoot%\system32\net.exe stop wuauserv", 0, True
    oShell.Run "%SystemRoot%\system32\net.exe start wuauserv", 0, True

    ' Run wuauclt.exe with resetauthorization
    sCmd = "%SystemRoot%\system32\wuauclt.exe /resetauthorization /detectnow"
    oShell.Run sCmd, 0, True

    MsgBox "Finished!", vbSystemModal+vbInformation

    '--------------------8<----------------------


    Alternatively:

    You can do it in a computer startup script (with a GPO) that runs as
    part of the boot up process (before the user logs in). It runs under
    the system context and has admin rights.

    The VBScript below will only delete the values once even if the script
    is run multiple times, by setting a registry marker.


    '--------------------8<----------------------
    Set oShell = CreateObject("WScript.Shell")

    sRegKey = "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate"

    ' suppress error in case values does not exist
    On Error Resume Next

    ' check for marker
    sIDDeleted = oShell.RegRead( sRegKey & "\IDDeleted")

    ' to be sure values is only deleted once, test on marker
    If sIDDeleted <> "yes" Then
    ' delete values
    oShell.RegDelete sRegKey & "\AccountDomainSid"
    oShell.RegDelete sRegKey & "\PingID"
    oShell.RegDelete sRegKey & "\SusClientId"

    ' Stop and start the Automatic updates service
    oShell.Run "%SystemRoot%\system32\net.exe stop wuauserv", 0, True
    oShell.Run "%SystemRoot%\system32\net.exe start wuauserv", 0, True

    ' Run wuauclt.exe with resetauthorization
    sCmd = "%SystemRoot%\system32\wuauclt.exe /resetauthorization /detectnow"
    oShell.Run sCmd, 0, True

    ' create marker
    oShell.RegWrite sRegKey & "\IDDeleted", "yes"
    End If
    '--------------------8<----------------------


    WSH 5.6 documentation (local help file) can be downloaded from here
    if you haven't got it already:
    http://msdn.microsoft.com/downloads/list/webdev.asp
     
    Torgeir Bakken \(MVP\), Jun 27, 2005
    #3
  4. Woody

    Woody Guest

    This is excellent news Torgeir, I will try this in the morning.

    Thankyou very much for your time and expert help.
     
    Woody, Jun 27, 2005
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.