This page is edited from the 1cmdfaq.txt faq-file contained in
my tscmd.zip
command line interface (CLI) collection. That zipped file has much
additional material, including a number of detached .cmd script
files. It is recommended that you also get the zipped version as a
companion.
Please see "
The Description and
the Index page" for the conditions of usage and other such
information.
11} How do I retain my original code page in these scripts?
@echo off & setlocal enableextensions
for /f "tokens=3 delims= " %%p in (
'mode con: codepage /status ^| find "Code page"') do (
set store_codepage_=%%p)
echo The stored codepage is %store_codepage_%
::
rem 850 (Multilingual Latin I)
mode con: codepage select=850
echo Whatever ...
::
mode con: codepage select=%store_codepage_%
endlocal & goto :EOF
Alternatively, and more concisely, one could have
@echo off & setlocal enableextensions
for /f "tokens=4" %%p in ('chcp') do set store_codepage_=%%p
echo The stored codepage is %store_codepage_%
::
rem 850 (Multilingual Latin I)
chcp 850
echo Whatever ...
::
chcp %store_codepage_%
endlocal & goto :EOF
More importantly, below are the regional settings which are used in
this FAQ collection and which directly affect the date and time
presentations. Hence, if your locale's diverge, some of the scripts
will need appropriate adjustments.
Likewise, some scripts may be affected by setting the time zone
environment variable
TZ. When set in
this FAQ, it will have the value
Europe/Helsinki or on occasions it must
not be set at all to get the datetime stamps right. For example, some
touch utilities confuse the datestamps if TZ is set. On the other hand
the MS-DOS PGP program requires that TZ is set.