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
    @thiih_
    Automatic driver updates can override the script and automatically install after a clean OS install the first time a manual update check is run with the script, but every time after that you can select which drivers to install with the script as far as I know. Although I know how and I could, I have decided to not override this behavior. It's better to have the drivers offered than to block them and the drivers to not be offered.

    Homer712 had lots of issues I never heard of from anyone else, but I think changes I made to the script to accommodate his issues helped the script.

    MMPC defender updates are usually behind Microsoft defender updates for some reason, and besides the much larger download size is another reason I don't like using it and are reasons I don't use MMPC defender updates with the script.

    Yes, I'm feeling a hell of a lot better, thanks for asking.
     
  2. thiih_

    thiih_ MDL Novice

    Mar 22, 2008
    27
    20
    0
    Indeed, you are right. Thats why I apply some Reg changes / GPO policies on my side to block drivers update in addition to Sledgehammer script, but depending on the system config, I left the drivers being updated by windows update (usually on older systems).

    I just tested a Hyper-V machine with a clean install and original Sledgehammer installed. Then I run the commands:

    -SignatureUpdate -mmpc command gives me that there is no update
    -SignatureUpdate command gives me an update

    But the info obtain from "Get-MpComputerStatus" before and after are identical. So maybe its just a "flag" misleading to an update that has been already done.

    I'll keep testing with mmpc.
     
  3. pf100

    pf100 Duct Tape Coder

    Oct 22, 2010
    2,069
    3,447
    90
    It just depends. MMPC can be behind ms update, but ms update is never behind MMPC.
     
  4. pf100

    pf100 Duct Tape Coder

    Oct 22, 2010
    2,069
    3,447
    90
    I just had an issue today with Windows 11 where a recent .net update wouldn't install with script 2.7.3 so I uninstalled the script, rebooted, and the update still wouldn't install through settings.
    So then I ran script 2.7.2 and the update still wouldn't install so I uninstalled the script, rebooted and it still wouldn't install through settings.
    Then I rebooted again while the script was uninstalled and the update installed through settings.
    It may have installed with the script that time, but right now I have no way of knowing if that's so or not.

    So there is a problem but I don't know if it's an actual windows 11 problem or not.
    I do know the script isn't breaking anything, so we'll see how things go in the near future.
    If the script needs to be modified I will fix it.
    Right now I don't know if anything needs to be done though.
    If anyone has any information or thoughts about Windows 11 and updates I'd like to hear it.
    I'll be asking around to try to find out more, so if you're having a problem installing an update just uninstall the script, reboot, and try again through settings.
    Like I said, I don't know if uninstalling the script is necessary because I don't have enough information yet.
     
  5. Carlos Detweiller

    Carlos Detweiller Emperor of Ice-Cream

    Dec 21, 2012
    6,316
    7,022
    210
    #1885 Carlos Detweiller, Oct 30, 2021
    Last edited: Oct 30, 2021
    For new dev builds, the script needs a slight overhaul. That's due to the removal of the wmic tool.

    Sledgehammer 2.7.3-rc1 has wmic calls in three locations:

    1. Line 105, for getting the OS build number.
    Code:
    for /f "tokens=2 delims==" %%a in ('wmic path Win32_OperatingSystem get BuildNumber /value') do (
      set /a WinBuild=%%a
    )
    
    2. Line 115, for querying the CPU architecture.
    Code:
    wmic cpu get AddressWidth /value|find "32">nul&&set PROCESSOR_ARCHITECTURE=X86||set PROCESSOR_ARCHITECTURE=AMD64
    3. Line 416, for getting the status of the wuauserv service.
    Code:
    WMIC Service WHERE "Name = 'Wuauserv'" GET Started | find /i "%status%" >nul && exit /b || (timeout /t 1 >nul & goto :wuauserv1)

    Replacements possible with VBScript or PS.

    o_O


    Edit: @abbodi1406 @mxman2k

    Maybe you have proposals for alternatives so the script can be repaired? Sorry for bothering you.
     
  6. Nocturnal_ru

    Nocturnal_ru MDL Novice

    Aug 14, 2017
    11
    1
    0
    Can I use Sledgehammer to update between major version of win, for example 2004->21H1? Or i should to uninstall the script and then update system?
     
  7. Carlos Detweiller

    Carlos Detweiller Emperor of Ice-Cream

    Dec 21, 2012
    6,316
    7,022
    210
    Sledgehammer's purpose is to block updates and upgrades. Best to uninstall it, do the upgrade, then reinstall it.
     
  8. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    16,141
    84,315
    340
    Code:
    for /f "tokens=1 delims==" %%a in ('powershell -nop -c "([WMI]'Win32_OperatingSystem=@').BuildNumber"') do (
      set /a WinBuild=%%a
    )
    :: or
    for /f "tokens=6 delims=[]. " %%a in ('ver') do set WinBuild=%%a
    
    Code:
    for /f "skip=2 tokens=2*" %%a in ('reg query "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v "PROCESSOR_ARCHITECTURE"') do set PROCESSOR_ARCHITECTURE=%%b
    
    Code:
    powershell -nop -c "([WMI]'Win32_Service=\"wuauserv\"').Started" | find /i "%status%" >nul && exit /b || (timeout /t 1 >nul & goto :wuauserv1)
    :: or
    sc query wuauserv | find /i "STOPPED" >nul && exit /b || (timeout /t 1 >nul & goto :wuauserv1)
    
     
  9. pf100

    pf100 Duct Tape Coder

    Oct 22, 2010
    2,069
    3,447
    90
    No bother at all and thanks for the post. I just found out about WMIC being dropped a few days ago.
    Recovery.cmd uses WMIC too but replacing it won't be a big deal.
    One way to get OS Architecture is: echo "%PROCESSOR_ARCHITECTURE%"
    One way to get OS build number is parsing the "ver" command
    One way to get wuauserv status is parsing: sc query wuauserv
    This is just off the top of my head and there are probably better/easier ways to do it with powershell or vbscript like you said.
    Everyone can expect a script update in the coming weeks. I've been farting around and not updating it for quite a while now, but since WMIC is being dropped I don't have a choice now.
    Also, @abbodi1406 replied while I was typing this :)

    Thank you @abbodi1406. Very helpful.
     
  10. Carlos Detweiller

    Carlos Detweiller Emperor of Ice-Cream

    Dec 21, 2012
    6,316
    7,022
    210
    Thank you all. I'll try to repair (read: patch) the script until the update arrives.
     
  11. pf100

    pf100 Duct Tape Coder

    Oct 22, 2010
    2,069
    3,447
    90
  12. Carlos Detweiller

    Carlos Detweiller Emperor of Ice-Cream

    Dec 21, 2012
    6,316
    7,022
    210
  13. rpo

    rpo MDL Expert

    Jan 3, 2010
    1,440
    1,420
    60
    The script tests the Processor_Architecture, but we need the OS_Architecture : a 32 bits Windows 10 the OS can may run on a 64 bits CPU
    for /f %%i in ('powershell "(Get-CimInStance CIM_OperatingSystem).OSArchitecture"') do set OS_ARCHITECTURE= %%i
     
  14. Carlos Detweiller

    Carlos Detweiller Emperor of Ice-Cream

    Dec 21, 2012
    6,316
    7,022
    210
    Thanks, have replaced that statement in both variants. Do you know if the result returned is localized in any form (have only English OS to test)?
     
  15. Carlos Detweiller

    Carlos Detweiller Emperor of Ice-Cream

    Dec 21, 2012
    6,316
    7,022
    210
    For some reason I don't get, the Powershell variant works for me but the other one doesn't.
     
  16. abbodi1406

    abbodi1406 MDL KB0000001

    Feb 19, 2011
    16,141
    84,315
    340
    Which doesn't?

    personally, i simply check the variables
    Code:
    if /i "%PROCESSOR_ARCHITECTURE%"=="amd64" set "xBit=x64"
    if /i "%PROCESSOR_ARCHITECTURE%"=="arm64" set "xBit=arm64"
    if /i "%PROCESSOR_ARCHITECTURE%"=="x86" if "%PROCESSOR_ARCHITEW6432%"=="" set "xBit=x86"
    if /i "%PROCESSOR_ARCHITEW6432%"=="amd64" set "xBit=x64"
    if /i "%PROCESSOR_ARCHITEW6432%"=="arm64" set "xBit=arm64"
     
  17. rpo

    rpo MDL Expert

    Jan 3, 2010
    1,440
    1,420
    60
    #1897 rpo, Nov 2, 2021
    Last edited: Nov 2, 2021
    On my French W11 system, the result is 64; this is language independant.

    Code:
    wmic cpu get AddressWidth /value|find "32">nul&&set PROCESSOR_ARCHITECTURE=X86||set PROCESSOR_ARCHITECTURE=AMD64
    if %PROCESSOR_ARCHITECTURE%==AMD64 (
     set "nsudovar=.\bin\NSudoCx64.exe"
     set "wumt=.\bin\wumt_x64.exe"
    ) else (
     set "nsudovar=.\bin\NSudoc.exe"
     set "wumt=.\bin\wumt_x86.exe"
    )

    replaced by :

    Code:
    for /f %%i in ('powershell "(Get-CimInStance CIM_OperatingSystem).OSArchitecture"') do (
    if %%i == 64 (
     set "nsudovar=.\bin\NSudoCx64.exe"
     set "wumt=.\bin\wumt_x64.exe"
    ) else (
     set "nsudovar=.\bin\NSudoc.exe"
     set "wumt=.\bin\wumt_x86.exe"
    ))
     
  18. Carlos Detweiller

    Carlos Detweiller Emperor of Ice-Cream

    Dec 21, 2012
    6,316
    7,022
    210
    #1898 Carlos Detweiller, Nov 2, 2021
    Last edited: Nov 2, 2021
    That's what I feared, the English OS returns "64-bit", not "64".

    Code:
    C:\>@for /f %i in ('powershell "(Get-CimInStance CIM_OperatingSystem).OSArchitecture"') do @echo %i
    64-bit
    
    C:\>_

    The non-Powershell variant (the second one) will, when I press the desired number in the configurator, consistently not do anything (it should start WuMgr or WUMT). The variant using Powershell works every time. I'm at a loss, but suspecting the line using sc.exe to query the service state.

    Will check again once I cleared out over 300GB of Snapshot data from this VM. :)
     
  19. Homer712

    Homer712 MDL Member

    Oct 22, 2018
    118
    45
    10
    Trying to follow along here with the latest changes and have a question. I have the script (v2.7.3 RC1) running perfectly on an older Dell laptop that is currently on Win 10 and has a 0% chance of ever being updated to Win11.

    1. Is there any reason that I would want to use any updated script?
    2. Once all the script changes are done, will there then be a Win 10 script and a Win 11 script?
     
  20. Carlos Detweiller

    Carlos Detweiller Emperor of Ice-Cream

    Dec 21, 2012
    6,316
    7,022
    210
    1. Windows 10 still has WMIC, so, you don't need to do anything at this point. It's only about the Dev builds of Windows 11 that have abolished WMIC.
    2. If the changes are eventually accepted into the script, they will work for Windows 10, too.