Skip to content

Commit f00baad

Browse files
committed
Improve error handling when /quiet is specified without admin rights
1 parent 4a4c1ee commit f00baad

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

EnglishizeCmd.bat

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,17 @@ set EnglishizeDir=%~d0%~p0
4747
if defined noAttrib goto :skipAdminCheck
4848
attrib -h "%windir%\system32" | find /i "system32" >nul 2>&1
4949
if %errorlevel% EQU 0 (
50-
if "%UACenabled%" EQU "1" (
50+
REM only when no parameter is specified should the script be elevated, as any supplied parameters cannot be carried across
51+
if /i "%~1" NEQ "/quiet" (
5152
REM only when UAC is enabled can this script be elevated. Otherwise, non-stop prompting will occur.
52-
cscript //NoLogo "%EnglishizeDir%Data\_elevate.vbs" "%EnglishizeDir%" "%EnglishizeDir%\EnglishizeCmd.bat" >nul 2>&1
53-
goto :EOF
53+
if "%UACenabled%" EQU "1" (
54+
cscript //NoLogo "%EnglishizeDir%Data\_elevate.vbs" "%EnglishizeDir%" "%EnglishizeDir%\EnglishizeCmd.bat" >nul 2>&1
55+
goto :EOF
56+
)
5457
) else (
58+
REM /quiet requires having admin rights in advance
5559
echo.
56-
echo ** WARNING: Script running without admin rights. Cannot continue.
60+
echo ** Englishize Cmd requires admin rights in advance for /quiet. Please run Command Prompt as admin.
5761
echo.
5862
pause
5963
goto :EOF
@@ -74,9 +78,9 @@ echo.
7478
echo [ Englishize Cmd v2.0 ]
7579
echo.
7680
echo.
77-
echo # This script changes command line interface to English.
81+
echo # This script changes command-line interface to English.
7882
echo.
79-
echo # Designed for localized non-English Windows Vista or above. Any languages.
83+
echo # Designed for localized non-English Windows Vista ^(Server 2008^) or above. Any languages.
8084
echo.
8185
echo # Note 1. A few programs without a .mui aren't affected, e.g. xcopy
8286
echo.
@@ -85,6 +89,8 @@ echo.
8589
echo 3. English MUI can be installed through Windows Update or Vistalizator
8690
echo to support GUI programs such as Paint.
8791
echo.
92+
echo 4. /quiet ^(optional^) can be specified to run Englishize Cmd in an unattended way
93+
echo.
8894
if /i "%~1" NEQ "/quiet" (
8995
echo Press any key to begin . . .
9096
pause >nul
@@ -133,7 +139,7 @@ if /i "%~1" NEQ "/quiet" (
133139
pause >nul
134140
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"
135141
) else (
136-
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"
142+
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"
137143
)
138144

139145
cls

RestoreCmd.bat

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,17 @@ set EnglishizeDir=%~d0%~p0
4747
if defined noAttrib goto :skipAdminCheck
4848
attrib -h "%windir%\system32" | find /i "system32" >nul 2>&1
4949
if %errorlevel% EQU 0 (
50-
if "%UACenabled%" EQU "1" (
50+
REM only when no parameter is specified should the script be elevated, as any supplied parameters cannot be carried across
51+
if /i "%~1" NEQ "/quiet" (
5152
REM only when UAC is enabled can this script be elevated. Otherwise, non-stop prompting will occur.
52-
cscript //NoLogo "%EnglishizeDir%Data\_elevate.vbs" "%EnglishizeDir%" "%EnglishizeDir%\RestoreCmd.bat" >nul 2>&1
53-
goto :EOF
53+
if "%UACenabled%" EQU "1" (
54+
cscript //NoLogo "%EnglishizeDir%Data\_elevate.vbs" "%EnglishizeDir%" "%EnglishizeDir%\RestoreCmd.bat" >nul 2>&1
55+
goto :EOF
56+
)
5457
) else (
58+
REM /quiet requires having admin rights in advance
5559
echo.
56-
echo ** WARNING: Script running without admin rights. Cannot continue.
60+
echo ** Englishize Cmd requires admin rights in advance for /quiet. Please run Command Prompt as admin.
5761
echo.
5862
pause
5963
goto :EOF
@@ -73,7 +77,7 @@ echo.
7377
echo [ Englishize Cmd v2.0 ]
7478
echo.
7579
echo.
76-
echo # This script restores the command line interface back to the original language
80+
echo # This script restores the command-line interface back to the original language
7781
echo.
7882
if /i "%~1" NEQ "/quiet" (
7983
echo Press any key to begin . . .
@@ -114,7 +118,7 @@ if /i "%~1" NEQ "/quiet" (
114118
pause >nul
115119
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"
116120
) else (
117-
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"
121+
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"
118122
)
119123
cls
120124
echo.

0 commit comments

Comments
 (0)