Sledgehammer - Windows 10 Update Control

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

  1. pf100

    pf100 MDL Expert

    Oct 22, 2010
    1,595
    2,286
    60
    #1281 pf100, May 10, 2019
    Last edited: May 10, 2019
    (OP)
  2. Windows_Addict

    Windows_Addict MDL Member

    Jul 19, 2018
    229
    292
    10
    If there is a problem in Admin rights elevation (due to WSH being blocked in the system or something) then the script will exit without error msg.
    Probably you can change it to, (line no. 87)
    Code:
    cmd /u /c echo Set UAC = CreateObject^("Shell.Application"^) : UAC.ShellExecute "%~0", "%params%", "", "runas", 1 > "%temp%\getadmin.vbs"&cscript //nologo "%temp%\getadmin.vbs" && exit /b || (echo Your Error msg. &pause>nul 2>&1&exit)
     
  3. pf100

    pf100 MDL Expert

    Oct 22, 2010
    1,595
    2,286
    60
  4. pf100

    pf100 MDL Expert

    Oct 22, 2010
    1,595
    2,286
    60
  5. pf100

    pf100 MDL Expert

    Oct 22, 2010
    1,595
    2,286
    60
  6. rpo

    rpo MDL Addicted

    Jan 3, 2010
    834
    605
    30
    @pf100 : code cleaning
    Replacement for lines 409-412
    Code:
    if %errorlevel%==5 call :startupdate bin\wumgr.exe 7971f918-a847-4430-9279-4a52d1efe18d -onclose close.cmd                   
    if %errorlevel%==4 call :startupdate bin\wumgr.exe  -update -offline 7971f918-a847-4430-9279-4a52d1efe18d -onclose close.cmd   
    if %errorlevel%==3 call :StartUpdate %wumt% -update "-onclose close.cmd"                                                       
    if %errorlevel%==2 call :StartUpdate bin\wumgr.exe -update -online 7971f918-a847-4430-9279-4a52d1efe18d -provisioned -onclose close.cmd
    Replacement for lines 452-455
    Code:
    if %errorlevel%==5 call :startupdate bin\wumgr.exe 7971f918-a847-4430-9279-4a52d1efe18d -onclose close.cmd                       
    if %errorlevel%==4 call :startupdate bin\wumgr.exe  -update -offline 7971f918-a847-4430-9279-4a52d1efe18d -onclose close.cmd
    if %errorlevel%==3 call :StartUpdate %wumt% -update "-onclose close.cmd"
    if %errorlevel%==2 call :StartUpdate bin\wumgr.exe -update -online 7971f918-a847-4430-9279-4a52d1efe18d -provisioned -onclose close.cmd
    Replacement for lines 626-692
    Code:
    (
    echo @echo off
    echo :loop
    echo net start wuauserv
    echo timeout /t 10
    echo goto loop
    )>WU-keep-alive.cmd
    (
    echo @echo off
    echo cd /d "%%~dp0"
    echo del WU-keep-alive.cmd
    echo .\bin\wub.exe /d /p
    echo del close.cmd ^& exit
    )>close.cmd
    call :wuauserv e
    echo CreateObject^("WScript.Shell"^).Run "WU-keep-alive.cmd",0 >WU-keep-alive.vbs&WU-keep-alive.vbs&del WU-keep-alive.vbs
    Start "" %*
    exit
     
  7. Windows_Addict

    Windows_Addict MDL Member

    Jul 19, 2018
    229
    292
    10
    Codes like cd /d "%~dp0" or anything which deals with pathname will not work if there are characters such as &@%^() in the path name.

    So if we put the codes regarding characters detections in the top of the script then it can show the error msg without unexpected exit.
    However, manually running the script as admin by right click will still fail to work with some characters such as &^()
    but still I suppose the user will give it a try by without manual run as admin, and that's where they can find out where is the problem.
     
  8. rpo

    rpo MDL Addicted

    Jan 3, 2010
    834
    605
    30
    Check if PC is connected to Internet :
    Code:
    powershell -nologo "If([Activator]::CreateInstance([Type]::GetTypeFromCLSID([Guid]'{DCB00C01-570F-4A9B-8D69-199FDBA5723B}')).IsConnectedToInternet){Exit 0}Else{Exit 1}"
    if %errorlevel%==0 (echo Connected to Internet) else (echo Not connected to Internet)
    pause
     
  9. pf100

    pf100 MDL Expert

    Oct 22, 2010
    1,595
    2,286
    60
    #1297 pf100, May 11, 2019
    Last edited: May 11, 2019
    (OP)
    Excellent. No more confusion over what server(s) to check.

    @rpo You're my hero.

    I've incorporated the code cleanup and other improvements.
    Now it's basically just a lot of cosmetics and a few other changes.
    If nothing unexpected happens, 2.6.1 should be out within a week or so.
    Why a week? Extensive testing. I want to make sure it's solid so no update will be needed for as long as possible.

    Realistically, at some point, once the script is perfected, it should never need to be updated again until Microsoft changes something about the "update hijacker" subsystem, or another script feature is needed.
    They haven't added anything new to force updates in a long time now and I can't think of one single thing the script doesn't do (the currently under development 2.6.1) that it needs to do.
    Well, maybe replace the locked hijacker folders with locked files with the same name, but that's on the back burner for now.

    I'll post a new rc version of the script to test when I think it's ready so I can run it by everybody. I've been working on it today but I have nothing finished yet. Cosmetics are a bitch. I should hopefully have something by tomorrow.

    I really appreciate the input from everybody. All the comments and suggestions and contributions over time have made this script 100 times better than I would have ever dreamed a few years ago.
     
  10. rpo

    rpo MDL Addicted

    Jan 3, 2010
    834
    605
    30
    Possible (to be tested) replacement of wub.exe by cmd files :
    For wub /e :
    Code:
    echo \Registry\Machine\SYSTEM\CurrentControlSet\Services\wuauserv [1 5 8 11 17] >%temp%\regini.ini
    rem  1 - Administrators Full Access
    rem  5 - Creator Full Access
    rem  8 - World Read Access
    rem 11 - Power Users Full Access
    rem 17 - System Full Access
    regini %temp%\regini.ini >nul 2>&1
    del %temp%\regini.ini
    sc config wuauserv start= delayed-auto >nul 2>&1
    net start wuauserv >nul 2>&1 
    For wub /d /p
    Code:
    net stop wuauserv >nul 2>&1
    sc config wuauserv start= disabled >nul 2>&1
    echo \Registry\Machine\SYSTEM\CurrentControlSet\Services\wuauserv [2 8 19] >%temp%\regini.ini
    rem  2 - Administrators Read Access
    rem  8 - World Read Access
    rem 19 - System Read Access
    regini %temp%\regini.ini >nul 2>&1
    del %temp%\regini.ini
     
  11. pf100

    pf100 MDL Expert

    Oct 22, 2010
    1,595
    2,286
    60
    That's awesome @rpo. I've never heard of regini before. Looks like a winner.
    I haven't been able to work on the script for the last few days because life got in the way. I'll send you an update as soon as I have it.
     
  12. rpo

    rpo MDL Addicted

    Jan 3, 2010
    834
    605
    30
    regini is an old program i never used before. The job could be done with acl processing, but it's an other story.