show debug info on failure, more error checking

This commit is contained in:
zeffy
2017-04-22 17:11:39 -07:00
parent 998a2a7e85
commit 6f62501e31

View File

@@ -14,18 +14,20 @@
:: You should have received a copy of the GNU General Public License
:: along with this program. If not, see <http://www.gnu.org/licenses/>.
echo Copyright (C) 2017 zeffy ^<https://github.com/zeffy^>
echo This program comes with ABSOLUTELY NO WARRANTY.
echo This is free software, and you are welcome to redistribute it
echo under certain conditions; see COPYING.txt for details.
echo.
net session >nul 2>&1 || (
echo This batch script requires administrator privileges. Right-click on
echo %~nx0 and select "Run as administrator".
goto :die
)
if not exist "%~dp0patches\" (
echo Patches folder not found! Make sure you extracted all the files from
echo the .zip, and the 'patches' folder is in the same location
echo as %~nx0, and try again.
goto :die
)
set "SYSTEM32_DIR=%systemroot%\System32"
set "WUAUENG_DLL=%SYSTEM32_DIR%\wuaueng.dll"
echo Checking system requirements...
@@ -37,40 +39,38 @@ if /I "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
goto :is_x64
)
if /I "%PROCESSOR_ARCHITECTURE%"=="x86" (
set "WINDOWS_BITNESS=x86"
set "WINDOWS_ARCHITECTURE=x86"
set "XDELTA3_EXE=%~dp0xdelta3-3.0.11-i686.exe"
goto :find_xdelta
goto :find_xdelta3
)
)
goto :unsupported
goto :unsupported_os
:is_x64
set "WINDOWS_BITNESS=x64"
set "WINDOWS_ARCHITECTURE=x64"
set "XDELTA3_EXE=%~dp0xdelta3-3.0.11-x86_64.exe"
:find_xdelta
:find_xdelta3
echo.
if not exist "%XDELTA3_EXE%" (
echo xdelta3 %WINDOWS_BITNESS% not found! Make sure you extracted all the files from
echo the .zip. Make sure both of the xdelta3 .exe files are in the same location
echo as %~nx0, and try again.
call :file_not_found "%XDELTA3_EXE%"
goto :die
)
wmic /output:stdout os get version | findstr "^6\.1\." >nul && (
set "WINDOWS_VER=6.1"
set "SUPPORTED_HOTFIXES=KB4015552 KB4015549 KB4015546 KB4012218"
echo Detected supported operating system: Windows 7 %WINDOWS_BITNESS%
echo Detected supported operating system: Windows 7 %WINDOWS_ARCHITECTURE%
goto :check_hotfix
)
wmic /output:stdout os get version | findstr "^6\.3\." >nul && (
set "WINDOWS_VER=8.1"
set "SUPPORTED_HOTFIXES=KB4015553 KB4015550 KB4015547 KB4012219"
echo Detected supported operating system: Windows 8.1 %WINDOWS_BITNESS%
echo Detected supported operating system: Windows 8.1 %WINDOWS_ARCHITECTURE%
goto :check_hotfix
)
:unsupported
:unsupported_os
echo Detected that you are using an unsupported operating system.
echo.
echo This patch only works on the following versions of Windows:
@@ -91,12 +91,13 @@ for %%a in (%SUPPORTED_HOTFIXES%) do (
)
)
echo Detected that no supported updates are installed! If you
echo are getting unsupported hardware errors in Windows Update, please
echo create an issue and post a list of any recently installed
echo Windows updates that could have introduced it, and I will try
echo to help you out.
echo Detected that no supported updates are installed! If you are getting
echo unsupported hardware errors in Windows Update, please create an issue
echo and I will try to help you out.
echo.
echo https://github.com/zeffy/kb4012218-19/issues
echo.
call :show_debug_info
goto :die
:confirmation
@@ -138,14 +139,14 @@ goto :ask
:begin
echo.
set "DELTA_FILE=%~dp0patches\Windows%WINDOWS_VER%-%INSTALLED_HOTFIX%-%WINDOWS_BITNESS%-%PATCH_TYPE%.xdelta"
set "SYSTEM32_DIR=%systemroot%\System32"
set "WUAUENG_DLL=%SYSTEM32_DIR%\wuaueng.dll"
for /f "delims=" %%a in ('wmic os get localdatetime ^| find "."') do set dt=%%a
set "TIMESTAMP=%dt:~0,4%-%dt:~4,2%-%dt:~6,2%_%dt:~8,2%-%dt:~10,2%-%dt:~12,2%"
set "BACKUP_FILE=%WUAUENG_DLL%_%TIMESTAMP%_%random%_before-%PATCH_TYPE%.bak"
set "ACL_TEMP_FILE=%temp%\wuaueng.dll_acl_%TIMESTAMP%_%random%.txt"
set "DELTA_FILE=%~dp0patches\Windows%WINDOWS_VER%-%INSTALLED_HOTFIX%-%WINDOWS_ARCHITECTURE%-%PATCH_TYPE%.xdelta"
if not exist "%DELTA_FILE%" (
call :file_not_found "%DELTA_FILE%"
goto :die
)
call :set_timestamp_var
set "BACKUP_FILE=%WUAUENG_DLL%_%TIMESTAMP%_before-%PATCH_TYPE%.bak"
set "ACL_TEMP_FILE=%temp%\wuaueng.dll_acl_%TIMESTAMP%.txt"
net stop wuauserv
@@ -174,7 +175,10 @@ if defined THERE_WAS_AN_ERROR (
echo If you didn't screw with the script or anything like that and this
echo error was unexpected, please create an issue and include the output
echo of this window in your post.
echo.
echo https://github.com/zeffy/kb4012218-19/issues
echo.
call :show_debug_info
) else (
echo Successfully %PATCH_TYPE%ed!
echo If you want to revert the changes that have been made for whatever
@@ -185,19 +189,72 @@ if defined THERE_WAS_AN_ERROR (
echo by renaming it back to wuaueng.dll, changing the owner back to
echo "NT Service\TrustedInstaller", and restoring the original permissions from
echo '%ACL_TEMP_FILE%'.
echo However, be careful to make sure you only restore the backup that is the same
echo However, make absolutely sure you only restore the backup that is the same
echo version as the current wuaueng.dll, or you could corrupt the WinSxS component
echo store.
)
:die
echo.
echo Press any key to close . . .
echo Press any key to exit...
pause >nul
exit
:cancel
echo.
echo Canceled by user input, press any key to close . . .
echo Canceled by user, press any key to exit...
pause >nul
exit
:show_debug_info
echo Gathering debugging information, please wait...
call :set_timestamp_var
set "DEBUG_LOG_FILE=%temp%\%~nx0-debuginfo_%TIMESTAMP%.log"
echo.>"%DEBUG_LOG_FILE%"
echo ^<details^>>>"%DEBUG_LOG_FILE%"
echo.>>"%DEBUG_LOG_FILE%"
echo ## Operating System>>"%DEBUG_LOG_FILE%"
echo.>>"%DEBUG_LOG_FILE%"
echo ```>>"%DEBUG_LOG_FILE%"
wmic os get BuildNumber,Caption,MUILanguages,OSArchitecture,OSLanguage,Version /value | findstr /V "^$" >>"%DEBUG_LOG_FILE%"
echo ```>>"%DEBUG_LOG_FILE%"
echo.>>"%DEBUG_LOG_FILE%"
echo ## Installed Hotfixes>>"%DEBUG_LOG_FILE%"
echo.>>"%DEBUG_LOG_FILE%"
echo ```>>"%DEBUG_LOG_FILE%"
wmic qfe get HotFixID,InstalledOn /value | findstr /V "^$" >>"%DEBUG_LOG_FILE%"
echo ```>>"%DEBUG_LOG_FILE%"
echo.>>"%DEBUG_LOG_FILE%"
echo ## wuaueng.dll Properties>>"%DEBUG_LOG_FILE%"
echo.>>"%DEBUG_LOG_FILE%"
echo ```>>"%DEBUG_LOG_FILE%"
certutil -hashfile "%WUAUENG_DLL%" MD5 | find /V "CertUtil" >>"%DEBUG_LOG_FILE%"
echo.>>"%DEBUG_LOG_FILE%"
certutil -hashfile "%WUAUENG_DLL%" SHA1 | find /V "CertUtil" >>"%DEBUG_LOG_FILE%"
echo.>>"%DEBUG_LOG_FILE%"
certutil -hashfile "%WUAUENG_DLL%" SHA256 | find /V "CertUtil" >>"%DEBUG_LOG_FILE%"
echo.>>"%DEBUG_LOG_FILE%"
wmic datafile where "name='%WUAUENG_DLL:\=\\%'" get CreationDate,FileSize,InstallDate,LastAccessed,LastModified,Version /value | findstr /V "^$" >>"%DEBUG_LOG_FILE%"
echo ```>>"%DEBUG_LOG_FILE%"
echo ^</details^>>>"%DEBUG_LOG_FILE%"
echo.
echo Done! Please copy the text from Notepad into your GitHub issue.
echo Opening log file in 5 seconds...
timeout /t 5 /nobreak >nul
start "" notepad "%DEBUG_LOG_FILE%"
exit /b
:set_timestamp_var
for /f "delims=" %%a in ('wmic os get localdatetime ^| find "."') do set dt=%%a
set "TIMESTAMP=%dt:~0,4%-%dt:~4,2%-%dt:~6,2%_%dt:~8,2%-%dt:~10,2%-%dt:~12,2%_%dt:~15,6%"
exit /b
:file_not_found
echo File "%~1" not found!
echo Make sure you extracted all the files from the release .zip and try again.
exit /b