Sledgehammer - Windows 10 Update Control

Discussion in 'MDL Projects and Applications' started by pf100, Nov 28, 2016.

  1. pf100

    pf100 Duct Tape Coder

    Oct 22, 2010
    2,069
    3,447
    90
    #1201 pf100, Apr 15, 2019
    Last edited: Apr 16, 2019
    (OP)
    That's because of wub.exe. That file has been a blessing, and a thorn in my side. Using some script speed up tricks in 2.6.0, rarely it will just "hang" for no apparent reason I can find so the script times out. There were multiple 2 and 3 second timeouts after each time wub.exe was run in 2.5.5 that really slowed the script down that were reduced to one "no more than one second" timeout after running wub.exe in 2.6.0.
    I could fix the rare hangs by 1) putting the 2 and 3 second timeouts back into the script, slowing it down, but I'm never going to put those timeouts back in, or 2) replacing wub.exe with the actual commands that wub is doing which I'm planning on in the future. I think it's a good trade-off because the hangs are rare, and the speed increase in 2.6.0 is definitely noticeable.
    Fixing that is on the to-do list.
     
  2. rpo

    rpo MDL Expert

    Jan 3, 2010
    1,440
    1,420
    60
    IMHO there is no need to put "the 2 and 3 second timeouts back into the script" and the 1s timeout at line 536 is not usefull because we are looping up to 10 times (leading to a timeout up to 10 seconds) if the wuauserv status is not changed to the desired value.
     
  3. rpo

    rpo MDL Expert

    Jan 3, 2010
    1,440
    1,420
    60
    I came to the same conclusion concerning the wub.exe replacement : change the reg entry with reg.exe and manage the authorization acces with nsudo.
    Good luck!
     
  4. app_raiser

    app_raiser MDL Junior Member

    Mar 18, 2018
    93
    42
    0
    #1205 app_raiser, Apr 16, 2019
    Last edited: Apr 16, 2019
    i ran the 2.6 0v9 script on productive machine (1809) and in vm (1607) as well. nice surprise to see waas medic is put on the backseat :)

    think "pleasing" or "benevolent" describes the behavior of windows after running the script best.

    well done! will provide more feedback!
     
  5. Carlos Detweiller

    Carlos Detweiller Emperor of Ice-Cream

    Dec 21, 2012
    6,316
    7,023
    210
    Thanks for the fruitful discussion. As said, I feel perfectly able to edit the script myself, my concern is with wrapping it up into the installer, again. Making an alternative, unlocked Installer would be nice, however, only if the next release is not right around the corner. If it is, you should dedicate your resources to getting it out. Once released, I'll use 2.6.0, anyway.

    As for WUMT vs. WuMgr, I know of two differences:
    1. WUMT still runs on and works for updating XP. That's the only reason I still use it.
    2. WUMT can mark problematic updates in the lists. @DavidXanatos already said that WuMgr will eventually catch up in that field.

    In other words, for a script targeting Windows 10, with updates you cannot really avoid, WUMT offers no additional value over WuMgr. No need to keep it (it's been over 2 years since its last update).
     
  6. thefly42

    thefly42 MDL Novice

    Jan 30, 2016
    14
    5
    0
    Hi again,
    I mentioned the time-out as an observation only, not as something that needs a fix. Am quite happy with Version 2.6.0v9?
    Thanks again.
     
  7. rpo

    rpo MDL Expert

    Jan 3, 2010
    1,440
    1,420
    60
    @pf100
    An idea to deal with wub.exe replacement :
    To avoid wuauserv running, stop it (sc stop wuauserv) and change the ImagePath key (of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\wuauserv) from "%systemroot%\system32\svchost.exe -k netsvcs -p" to blank : the service can't be restarted again, it will fail. To restart the service, restore the previous suppressed value in the registry and start the service (sc start wuauerv).
     
  8. pf100

    pf100 Duct Tape Coder

    Oct 22, 2010
    2,069
    3,447
    90
    A harder thing to see is that Update Orchestrator can't do anything except when you're actually updating using the script, when it's harmless. Also, Windows 10 Update Assistant can't be installed or run. The script uninstalls it if found.
    I have to do it in the script.
    I ran across the timeout during script testing and decided it wasn't a problem. It will be completely fixed at some point.
    You just single handedly made things a lot easier with that. I just talked to the board who okayed it, and you're getting a promotion and we're doubling your salary. :)
     
  9. rpo

    rpo MDL Expert

    Jan 3, 2010
    1,440
    1,420
    60
    Here is a test script i run on a W7 VM :
    Code:
    @echo off
    cls
    call :wuauserv d
    pause
    call :wuauserv e
    pause
    goto :fin
    
    :wuauserv
    if /i "%1"=="e" (
    echo enable
    reg add HKLM\SYSTEM\CurrentControlSet\Services\wuauserv  /v ImagePath /t REG_EXPAND_SZ /d "%%systemroot%%\system32\svchost.exe -k netsvcs" /f
    net start wuauserv
    exit /b
    )
    if /i "%1"=="d" (
    echo disable
    net stop wuauserv
    reg delete HKLM\SYSTEM\CurrentControlSet\Services\wuauserv  /v ImagePath /f
    exit /b
    )
    :fin
    echo fin test
    pause
    In order to disable, I stop the wuauserv service and delete the ImagePath in the wuauserv subkey entry in the registry. To enable, i recreate the ImagePath and start the service.
    For w10 the ImagePath is %systemroot%\system32\svchost.exe -k netsvcs -p.
    I use net start/net stop and not sc start/sc stop because net.exe is synchronous, so no need for a timeout loop.
     
  10. pf100

    pf100 Duct Tape Coder

    Oct 22, 2010
    2,069
    3,447
    90
    That's perfect. Thanks again.
    I'll be adding [HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\wuauserv] necessary commands to the list also.
    Unless anyone knows why I shouldn't.
    I know of no reason not to.

    One thing about this: it'll make wub.exe incompatible with the script since it's two different methods.

    1)I'll have to figure out recovery code and make it run when the script starts for people who used wub with the script.

    2) I need to make an announcement that wub support is ending in say, some number of months.
    That's the only way I have of communicating with 99.9% of those who use the script.
    Provide:
    a) a message in the OP
    b) a message in the installer
    c) a message at the top of the readme, and
    d) a file named wub_support_ending.txt in the script folder with more info inside about wub support ending in v2.6.1, and that they can't be used together.

    Therefore, I have little choice but to put the changes in the release after v2.6.0: v2.6.1.

    or

    I could alter it to make it do what wub does.
     
  11. rpo

    rpo MDL Expert

    Jan 3, 2010
    1,440
    1,420
    60
    #1212 rpo, Apr 18, 2019
    Last edited: Apr 19, 2019
    With Autoit, it should be possible to create a WUB.exe like program. Here is a draft
    Code:
    #pragma compile(ProductName,Wub.exe replacement)
    AutoItSetOption ("MustDeclareVars",1)
    #pragma compile(x64,false)
    #RequireAdmin
    #include <Constants.au3>
    #include <GuiConstantsEx.au3>
    Global $Return, $par1="",$par2=""
    Global $idOptE, $idOptD, $idOptDP, $idCancelBtn, $idOKBtn
    if $CmdLine[0]=0 Then
     GUICreate("Manage wuauserv", 260, 180)
     $idOptE=GUICtrlCreateRadio("Enable WU", 70, 20,100)
     GUICtrlSetState(-1, $GUI_CHECKED)
     $idOptD=GUICtrlCreateRadio("Disable WU", 70, 50,100)
     $idOptDP=GUICtrlCreateRadio("Disable WU and Protect", 70, 80, 180)
     $idCancelBtn=GUICtrlCreateButton("Cancel", 10,120, 100, 30)
     $idOKBtn=GUICtrlCreateButton("OK", 150,120, 100, 30)
     $par1="/E"
     $par2=""
     GUISetState(@SW_SHOW)
     While 1
      Switch GUIGetMsg()
       Case $idCancelBtn
        Exit
       Case $idOKBtn
        wuauserv()
       Case $idOptE
        $par1="/E"
        $par2=""
       Case $idOptD
        $par1="/D"
        $par2="" 
       Case $idOptDP
        $par1="/D"
        $par2="/P"   
      EndSwitch
     WEnd
    Else
    $par1=StringUpper($CmdLine[1])
    if $CmdLine[0]=2 then $par2=StringUpper($CmdLine[2])
    wuauserv()
    Exit
    EndIf
    func wuauserv()
     If $par1="/E" OR $par2="/E"Then
      $return= RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\wuauserv","ImagePath","REG_EXPAnd_SZ","%systemroot%\system32\svchost.exe -k netsvcs -p")
    ;  MsgBox($MB_SYSTEMMODAL,"","The return code from reg was: " & $Return)
      $return=ShellExecuteWait('net.exe','start wuauserv',"","",@SW_HIDE)
    ;  MsgBox($MB_SYSTEMMODAL, "","The return code from net was: " & $Return)
     Else
      If $par1="/D" OR $par2="/D" then
       $return=ShellExecuteWait('net.exe','stop wuauserv',"","",@SW_HIDE)
    ;   MsgBox($MB_SYSTEMMODAL, "", "The return code from net was: " & $Return)
      EndIf
      If $par1="/P" OR $par2="/P" then
       $return= RegWrite("HKLM\SYSTEM\CurrentControlSet\Services\wuauserv", "ImagePath", "REG_EXPAnd_SZ", "")
    ;   MsgBox($MB_SYSTEMMODAL,"","The return code from reg was: " & $Return)
      EndIf 
     EndIf 
    EndFunc
    
    
    .
     
  12. rpo

    rpo MDL Expert

    Jan 3, 2010
    1,440
    1,420
    60
  13. yatopp

    yatopp MDL Novice

    Jul 17, 2011
    41
    12
    0
    New version of WUB, wonder if it helps your issues with it.

    Release date: April 21, 2019

    1. [ ADDED ] - GUI option for services which added to Ini
    2. [ FIXED ] - Some Parts of the software recoded (Improved)
     
  14. pf100

    pf100 Duct Tape Coder

    Oct 22, 2010
    2,069
    3,447
    90
    3. [STABLE] 2.6.0v9 (with a slight cosmetic MS-DEFCON edit, so 2.6.0v10)

    The script is stable with old closed source wub.exe, (I know what it does, and what it sometimes doesn't do), so I think put the new changes in the next release after more testing. A lot of testing. I've been tweaking it here and there for almost 5 months now, so it's due. If not it might be another month or more. Except for the WuMgr expert, etc. modes, I might try to squeeze that in if I can.
     
  15. app_raiser

    app_raiser MDL Junior Member

    Mar 18, 2018
    93
    42
    0
    i wondered were the folder came from but left it untouched (did not takeowned 'n trashed it), guessing your script takes care of this "assistant" too! :)

    there are no bugs i could report so far! is there a new release (after 2.6 0.9) i can test yet?!

    greetings!