C:\_G\WWW\~ELISANET\INFO\tscmd165.html
<http://www.elisanet.fi/tsalmi/info/tscmd165.html>
Copyright © 2003- by Prof. Timo Salmi  
Last modified Fri 7-Dec-2018 10:59:13

 
Assorted NT/2000/XP/.. CMD.EXE Script Tricks
From the html version of the tscmd.zip 1cmdfaq.txt file
To the Description and the Index
 

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.



165} How do I get the date and time separators and the local formats?

You may first wish to revisit item #1.

  @echo off & setlocal enableextensions
  set tmpfile_=%temp%\cmdfaq.tmp
  reg query "HKEY_CURRENT_USER\Control Panel\International">"%tmpfile_%"
  ::
  for /f "tokens=3" %%a in ('more "%tmpfile_%"^|find "sDate "') do (
    set sDate_=%%a)
  if defined sDate_ (
    echo sDate_=%sDate_%
    ) else (
    echo sDate_=Space or none)
  ::
  for /f "tokens=3" %%a in ('more "%tmpfile_%"^|find "sShortDate "') do (
    set sShortDate_=%%a)
  if defined sShortDate_ (
    echo sShortDate_=%sShortDate_%
    ) else (
    echo sShortDate_=none)
  ::
  for /f "tokens=3" %%a in ('more "%tmpfile_%"^|find "sTime "') do (
    set sTime_=%%a)
  if defined sTime_ (
    echo sTime_=%sTime_%
    ) else (
    echo sTime_=Space or none)
  ::
  for /f "tokens=3" %%a in ('more "%tmpfile_%"^|find "sTimeFormat "') do (
    set sTimeFormat_=%%a)
  if defined sTimeFormat_ (
    echo sTimeFormat_=%sTimeFormat_%
    ) else (
    echo sTimeFormat_=none)
  ::
  for %%f in ("%temfile_%") do if exist %%f del %%f
  endlocal & goto :EOF

The output might be e.g.
  C:\_D\TEST>cmdfaq
  sDate_=.
  sShortDate_=dd.MM.yyyy
  sTime_=:
  sTimeFormat_=HH:mm:ss

Or, more concisely
  @echo off & setlocal enableextensions
  for /F "tokens=1,2,*" %%a in (
    'reg query "HKCU\Control Panel\International"
      ^|findstr "sDate sShortDate sTime sTimeFormatsYearMonth"') do (
        set %%a=%%c)
  echo sDate=%sDate%
  echo sShortDate=%sShortDate%
  echo sTime=%sTime%
  echo sTimeFormat=%sTimeFormat%
  endlocal & goto :EOF

The output might be e.g.
  C:\_D\TEST>cmdfaq
  sDate=.
  sShortDate=dd.MM.yyyy
  sTime=:
  sTimeFormat=HH:mm:ss

[Previous] [Next]

C:\_G\WWW\~ELISANET\INFO\tscmd165.html
C:\_G\WWW\~ELISANET\FTPCMD\TSALMI.CMD /tscmd165
http://www.elisanet.fi/tsalmi/info/tscmd165.html
file:///c:/_g/www/~elisanet/info/tscmd165.html