来自http://www.cn-dos.net/forum/viewthread.php?tid=41857- @echo off
- rem 需要reg.exe的支持
- for /f "skip=4 delims= " %%a in ('reg query "HKEY_CURRENT_USER\Control Panel\International" /v sShortDate') do set DateFormat=%%a
- set DateFormat=%DateFormat:~-8%
- reg add "HKEY_CURRENT_USER\Control Panel\International" /v sShortDate /t REG_SZ /d yyyy-M-d /f>nul
- set Today=%date: =%
- reg add "HKEY_CURRENT_USER\Control Panel\International" /v sShortDate /t REG_SZ /d %DateFormat% /f>nul
- if "%Today:~0,1%" gtr "9" (
- set Today=%Today:~-10%
- ) else (
- set Today=%Today:~0,10%
- )
- echo %Today%
复制代码
- @echo off
- rem 需要保证注册表编辑器没有处于锁定状态
- regedit /e "%temp%\bak.reg" "HKEY_CURRENT_USER\Control Panel\International"
- >aDate.reg echo REGEDIT4
- >>aDate.reg echo.
- >>aDate.reg echo [HKEY_CURRENT_USER\Control Panel\International]
- >>aDate.reg echo "sShortDate"="yyyy-MM-dd"
- regedit /s aDate.reg&&del aDate.reg
- set Today=%date: =%
- regedit /s "%temp%\bak.reg"&&del "%temp%\bak.reg"
- if "%Today:~0,1%" gtr "9" (
- set Today=%Today:~-10%
- ) else (
- set Today=%Today:~0,10%
- )
- echo %Today%
复制代码 贴两个出来,原来还有个这样的帖子。
[ 本帖最后由 BBCC 于 2008-11-14 19:39 编辑 ] |