'capture existing shortdate format in sShortDate
for /f "tokens=3" %%a in ('reg query "hkcu\control panel\international" /v sShortDate ^| find /i "sshortdate"') do SET sShortDate=%%a
'set shortdate to desired output.
reg add "hkcu\control panel\international" /v sShortDate /t reg_sz /d "MMMM dd, yyyy" /f
echo %date%
'set shortdate back to original format.
reg add "hkcu\control panel\international" /v sShortDate /t reg_sz /d "%sShortDate%" /f
With some hefty code and liklihood of making mistakes across different machines with dates setup differently yes... or... you could use a VB Script. You can call that from a batch file still:
wscript.echo MonthName(Month(date())) & ", " & DAY(date()) & " " & Year(date())
save the above line as getdate.vbs say
Then in a batch file you can do:
cscript //nologo getdate.vbs to show it.
To get it into a variable use:
@echo off
for /f "tokens=* delims=" %%a in ('cscript //nologo getdate.vbs') do set thedate=%%a
echo %thedate%
You can create the VBS on the fly from a batch file using:
@echo off
if not exist getdate.vbs echo wscript.echo MonthName(Month(date())) & ", " & DAY(date()) & " " & Year(date())>getdate.vbs
for /f "tokens=* delims=" %%a in ('cscript //nologo getdate.vbs') do set thedate=%%a
echo %thedate%