Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1914
  • Last Modified:

How to get Short date and Long date format with DOS shell code

From Start->Settings->Control panel->Regional and Language Options, we can get the Short Date and Long date as wellas the other info. How to programmatically get the info out with DOS shell commands or the other programming languages?
0
jl66
Asked:
jl66
  • 2
1 Solution
 
QlemoC++ DeveloperCommented:
You do not have access to the locale data in DOS. You have to use e.g. PowerShell or WSH for this.
Do you want the date formatted, or only the format itself?
0
 
jl66Author Commented:
Thanks for reply. What I really want is to get what in the drop-down bpx (For example, English (United States) ) and get the Short date out (4/27/2009).
0
 
AmazingTechCommented:
Here's a batch file that uses REG to extract what is setup in the registry. You can convert ENU to English (United States) but you'll need to figure out the 3 letters for each code.
@ECHO OFF
Set sShortDate=
Set sLanguage=
for /f "tokens=2,*" %%a in ('reg query "hkcu\control panel\international" ^|
find /i "sshortdate"') do Set sShortDate=%%b
for /f "tokens=2,*" %%a in ('reg query "hkcu\control panel\international" ^|
find /i "slanguage"') do Set sLanguage=%%b
 
ECHO Short date is %sShortDate%
ECHO Language is %sLanguage%

Open in new window

0
 
AmazingTechCommented:
Opps the for needs to be on 1 line.
@ECHO OFF
Set sShortDate=
Set sLanguage=
for /f "tokens=2,*" %%a in ('reg query "hkcu\control panel\international" ^| find /i "sshortdate"') do Set sShortDate=%%b
for /f "tokens=2,*" %%a in ('reg query "hkcu\control panel\international" ^| find /i "slanguage"') do Set sLanguage=%%b
 
ECHO Short date is %sShortDate%
ECHO Language is %sLanguage%

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now