Skip to content

Commit

Permalink
Improve error handling when /quiet is specified without admin rights
Browse files Browse the repository at this point in the history
  • Loading branch information
wandersick committed Jul 4, 2020
1 parent 4a4c1ee commit f00baad
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 13 deletions.
20 changes: 13 additions & 7 deletions EnglishizeCmd.bat
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@ set EnglishizeDir=%~d0%~p0
if defined noAttrib goto :skipAdminCheck
attrib -h "%windir%\system32" | find /i "system32" >nul 2>&1
if %errorlevel% EQU 0 (
if "%UACenabled%" EQU "1" (
REM only when no parameter is specified should the script be elevated, as any supplied parameters cannot be carried across
if /i "%~1" NEQ "/quiet" (
REM only when UAC is enabled can this script be elevated. Otherwise, non-stop prompting will occur.
cscript //NoLogo "%EnglishizeDir%Data\_elevate.vbs" "%EnglishizeDir%" "%EnglishizeDir%\EnglishizeCmd.bat" >nul 2>&1
goto :EOF
if "%UACenabled%" EQU "1" (
cscript //NoLogo "%EnglishizeDir%Data\_elevate.vbs" "%EnglishizeDir%" "%EnglishizeDir%\EnglishizeCmd.bat" >nul 2>&1
goto :EOF
)
) else (
REM /quiet requires having admin rights in advance
echo.
echo ** WARNING: Script running without admin rights. Cannot continue.
echo ** Englishize Cmd requires admin rights in advance for /quiet. Please run Command Prompt as admin.
echo.
pause
goto :EOF
Expand All @@ -74,9 +78,9 @@ echo.
echo [ Englishize Cmd v2.0 ]
echo.
echo.
echo # This script changes command line interface to English.
echo # This script changes command-line interface to English.
echo.
echo # Designed for localized non-English Windows Vista or above. Any languages.
echo # Designed for localized non-English Windows Vista ^(Server 2008^) or above. Any languages.
echo.
echo # Note 1. A few programs without a .mui aren't affected, e.g. xcopy
echo.
Expand All @@ -85,6 +89,8 @@ echo.
echo 3. English MUI can be installed through Windows Update or Vistalizator
echo to support GUI programs such as Paint.
echo.
echo 4. /quiet ^(optional^) can be specified to run Englishize Cmd in an unattended way
echo.
if /i "%~1" NEQ "/quiet" (
echo Press any key to begin . . .
pause >nul
Expand Down Expand Up @@ -133,7 +139,7 @@ if /i "%~1" NEQ "/quiet" (
pause >nul
start "" "%comspec%" /c "help&echo.&echo # Successful if the above is displayed in English.&echo.&echo # Note: This window will close automatically in 10 seconds.&echo.&ping 127.0.0.1 -n 10 >nul 2>&1"
) else (
start "" "%comspec%" /c "help&echo.&echo # Successful if the above is displayed in English.&echo.&echo # Note: This window will close automatically in 5 seconds.&echo.&ping 127.0.0.1 -n 5 >nul 2>&1"
start "" "%comspec%" /c "help&echo.&echo # Successful if the above is displayed in English.&echo.&echo # Note: This window will close automatically in 10 seconds.&echo.&ping 127.0.0.1 -n 10 >nul 2>&1"
)

cls
Expand Down
16 changes: 10 additions & 6 deletions RestoreCmd.bat
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@ set EnglishizeDir=%~d0%~p0
if defined noAttrib goto :skipAdminCheck
attrib -h "%windir%\system32" | find /i "system32" >nul 2>&1
if %errorlevel% EQU 0 (
if "%UACenabled%" EQU "1" (
REM only when no parameter is specified should the script be elevated, as any supplied parameters cannot be carried across
if /i "%~1" NEQ "/quiet" (
REM only when UAC is enabled can this script be elevated. Otherwise, non-stop prompting will occur.
cscript //NoLogo "%EnglishizeDir%Data\_elevate.vbs" "%EnglishizeDir%" "%EnglishizeDir%\RestoreCmd.bat" >nul 2>&1
goto :EOF
if "%UACenabled%" EQU "1" (
cscript //NoLogo "%EnglishizeDir%Data\_elevate.vbs" "%EnglishizeDir%" "%EnglishizeDir%\RestoreCmd.bat" >nul 2>&1
goto :EOF
)
) else (
REM /quiet requires having admin rights in advance
echo.
echo ** WARNING: Script running without admin rights. Cannot continue.
echo ** Englishize Cmd requires admin rights in advance for /quiet. Please run Command Prompt as admin.
echo.
pause
goto :EOF
Expand All @@ -73,7 +77,7 @@ echo.
echo [ Englishize Cmd v2.0 ]
echo.
echo.
echo # This script restores the command line interface back to the original language
echo # This script restores the command-line interface back to the original language
echo.
if /i "%~1" NEQ "/quiet" (
echo Press any key to begin . . .
Expand Down Expand Up @@ -114,7 +118,7 @@ if /i "%~1" NEQ "/quiet" (
pause >nul
start "" "%comspec%" /c "help&echo.&echo # Successful if the above is displayed in the original language.&echo.&echo # Note 1: It may not reflect now if the restorer was run elevated.&echo.&echo # Note 2: This window will close automatically in 10 seconds.&echo.&ping 127.0.0.1 -n 10 >nul 2>&1"
) else (
start "" "%comspec%" /c "help&echo.&echo # Successful if the above is displayed in the original language.&echo.&echo # Note 1: It may not reflect now if the restorer was run elevated.&echo.&echo # Note 2: This window will close automatically in 5 seconds.&echo.&ping 127.0.0.1 -n 5 >nul 2>&1"
start "" "%comspec%" /c "help&echo.&echo # Successful if the above is displayed in the original language.&echo.&echo # Note 1: It may not reflect now if the restorer was run elevated.&echo.&echo # Note 2: This window will close automatically in 10 seconds.&echo.&ping 127.0.0.1 -n 10 >nul 2>&1"
)
cls
echo.
Expand Down

0 comments on commit f00baad

Please sign in to comment.