@echo off

echo expanding msu...

for /f "delims=" %%i in ('dir /b Windows8.1-KB917607-*.msu') do set msufile=%%i
md ContentMSU
expand -F:* %msufile% ContentMSU >NUL
cd ContentMSU
md ContentCAB
expand -F:* Windows8.1-KB917607-*.cab ContentCAB >NUL
cd ContentCAB

echo getting MUI language string...

for /f "delims=" %%i in ('wmic os get MUILanguages ^| find "{"') do set muilang=%%i
for /f delims^=^"^ tokens^=2 %%i in ('echo %muilang%') do set muilang=%%i

echo getting architecture from filename...

echo.%msufile% | findstr /C:"x64" 1>nul
if errorlevel 1 (
set arch=x86
) ELSE (
set arch=amd64
)

echo finding correct files for MUI language...

for /f "delims=" %%i in ('dir /B winhlp32.exe.mui /s ^| find "%arch%" ^| find /i "%muilang%"') do set muidir=%%i
for /f "delims=" %%i in ('dir /B winhlp32.exe /s ^| find "%arch%"') do set exedir=%%i

echo replacing files in %windir%...

takeown /f "%SystemRoot%\%muilang%\winhlp32.exe.mui"
icacls "%SystemRoot%\%muilang%\winhlp32.exe.mui" /grant "%UserName%":F
ren %SystemRoot%\%muilang%\winhlp32.exe.mui winhlp32.exe.mui.w10
copy %muidir% %SystemRoot%\%muilang%\winhlp32.exe.mui

takeown /f "%SystemRoot%\winhlp32.exe"
icacls "%SystemRoot%\winhlp32.exe" /grant "%UserName%":F
ren %SystemRoot%\winhlp32.exe winhlp32.exe.w10
copy %exedir% %SystemRoot%\winhlp32.exe

echo cleaning up...

cd ..
cd ..
rd /s /q ContentMSU

echo done!

pause