China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-06 08:17
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to execute different commands based on different dates under DOS View 789 Replies 4
Original Poster Posted 2007-10-28 13:59 ·  中国 福建 南平 电信
初级用户
Credits 20
Posts 8
Joined 2007-10-28 12:29
18-year member
UID 101010
Gender Male
Status Offline
Experts, I'm doing data backup and need to judge by the day of the week which corresponding files to compress. How should I write the batch file? I just looked it up and someone said to use %date%, but on my system %date% only returns the date and not the day of the week. What should I do? Waiting online
Floor 2 Posted 2007-10-28 14:30 ·  中国 福建 南平 电信
初级用户
Credits 20
Posts 8
Joined 2007-10-28 12:29
18-year member
UID 101010
Gender Male
Status Offline
An update on the problem: the issue that %date% only returns the date has already been solved, but now a new problem has come up. For %date% to show the time, the system date format must be set to yyyy-mm-dd dddd, but my office system requires the date format to be yyyy-mm-dd. Is it possible to set it to yyyy-mm-dd dddd before the batch command runs, and set it back to yyyy-mm-dd after it finishes?
Floor 3 Posted 2007-10-28 14:33 ·  中国 福建 南平 电信
初级用户
Credits 20
Posts 8
Joined 2007-10-28 12:29
18-year member
UID 101010
Gender Male
Status Offline
regedit -s DateFormatA.reg
if %date:~-3%==Sunday call rar.bat
pause
regedit -s DateFormatB.reg
pause
In DateFormatA.reg, set the date format to yyyy-mm-dd dddd
In DateFormatB.reg, set the date format to yyyy-mm-dd
This doesn't work. The date doesn't get set back; it seems the second reg wasn't executed
Floor 4 Posted 2007-10-28 21:13 ·  中国 福建 福州 电信
初级用户
Credits 20
Posts 8
Joined 2007-10-28 12:29
18-year member
UID 101010
Gender Male
Status Offline
No reply?
Floor 5 Posted 2007-10-29 13:11 ·  中国 上海 联通
版主
★★★★★
Credits 9,023
Posts 5,017
Joined 2007-05-31 19:39
19-year member
UID 89899
Gender Male
Status Offline
@echo off
rem Before executing the batch command
reg add "HKEY_CURRENT_USER\Control Panel\International" /v sShortDate /t REG_SZ /d "yyyy-mm-dd dddd" /f

rem After executing the batch command
reg add "HKEY_CURRENT_USER\Control Panel\International" /v sShortDate /t REG_SZ /d "yyyy-mm-dd" /f
Forum Jump: