|
gskys123
初级用户
 
积分 26
发帖 7
注册 2006-9-6 来自 四川
状态 离线
|
『楼 主』:
bat里面怎样获得当天是星期几??
使用 LLM 解释/回答一下
写一个自动关机的批处理文件
需要对不同的星期几设定不同的时间关机,那么在bat里面怎样获得当天是星期几??
并把它副给一个变量进行判断??
谢谢!!!!!!
比如我要判断今天是不是星期5或6. 若不是,则执行b.bat; 若是, 星期5或6则执行a.bat.
该怎么写呀? 谢谢!
~~~新手上路还望大家多多帮助~~~
Last edited by gskys123 on 2006-9-10 at 22:13 ]
To write an automatic shutdown batch file and get the current day of the week in a batch script to make different shutdown time settings for different days of the week, you can use the following method:
```batch
@echo off
for /f "tokens=2 delims==" %%a in ('wmic os get LocalDateTime /value') do set "dt=%%a"
set "weekday=%dt:~8,2%"
if "%weekday%"=="05" (
echo Today is Friday, execute a.bat
call a.bat
) else if "%weekday%"=="06" (
echo Today is Saturday, execute a.bat
call a.bat
) else (
echo Today is not Friday or Saturday, execute b.bat
call b.bat
)
```
Explanation: First, use `wmic os get LocalDateTime /value` to get the system's date and time information, then extract the day of the week part (`%dt:~8,2%` gets the 9th and 10th characters, which represent the day of the week in the format like "05" for Friday, "06" for Saturday). Then make judgments based on the value of the `weekday` variable, and execute different batch files accordingly.
Please note that the above code is a basic example, and you can adjust it according to your specific actual needs.
Last edited by gskys123 on 2006-9-10 at 22:13 ]
|
|
2006-9-10 10:45 |
|
|
vkill
金牌会员
     
积分 4103
发帖 1744
注册 2006-1-20 来自 甘肃.临泽
状态 离线
|
『第 2 楼』:
使用 LLM 解释/回答一下
如果你 echo %date% 显示如:2006-09-10 星期日 ,则下面这个可以
echo %date% |find "星期五" && call a.bat ||call b.bat
echo %date% |find "星期六" && call a.bat ||call b.bat
If you echo %date% shows like: 2006-09-10 Sunday, then the following can
echo %date% |find "Friday" && call a.bat ||call b.bat
echo %date% |find "Saturday" && call a.bat ||call b.bat
|
|
2006-9-11 00:55 |
|
|
fastslz
铂金会员
       DOS一根葱
积分 5493
发帖 2315
注册 2006-5-1 来自 上海
状态 离线
|
『第 3 楼』:
使用 LLM 解释/回答一下
查看帮助
HH ntcmds.chm::/net_user.htm
范例
要显示本地计算机上所有用户帐户的列表,请键入:
net user
要查看用户帐户 jimmyh 的信息,请键入:
net user jimmyh
要添加 Jay Jamison 的用户帐户,登录权限从星期一到星期五的早晨 8 点到下午 5 点(时间指定中没有间隔),且使用强制密码 (jayj) 和用户全名,请键入:
net user jayj /add /passwordreq:yes /times:monday-friday,8am-5pm/fullname:"Jay Jamison"
要使用 24 小时制表示法设置 johnsw 的登录时间(早晨 8 点到下午 5 点),请键入:
net user johnsw /time:M-F,08:00-17:00
要使用 12 小时制表示法设置 johnsw 的登录时间(早晨 8 点到下午 5 点),请键入:
net user johnsw /time:M-F,8am-5pm
要指定 marysl 的登录时间为星期一的早晨 4 点到下午 5 点、星期二的下午 1 点到 3 点以及星期三到星期五的上午 8 点到下午 5 点,请键入:
net user marysl /time:M,4am-5pm;T,1pm-3pm;W-F,8:00-17:00
View Help
HH ntcmds.chm::/net_user.htm
Examples
To display a list of all user accounts on the local computer, type:
net user
To view information about the user account jimmyh, type:
net user jimmyh
To add a user account for Jay Jamison, with logon permissions from Monday to Friday, 8 AM to 5 PM (no spaces in the time specification), and a forced password (jayj) and full name for the user, type:
net user jayj /add /passwordreq:yes /times:monday-friday,8am-5pm/fullname:"Jay Jamison"
To set johnsw's logon time using 24-hour notation (8 AM to 5 PM), type:
net user johnsw /time:M-F,08:00-17:00
To set johnsw's logon time using 12-hour notation (8 AM to 5 PM), type:
net user johnsw /time:M-F,8am-5pm
To specify marysl's logon time as 4 AM to 5 PM on Monday, 1 PM to 3 PM on Tuesday, and 8 AM to 5 PM on Wednesday to Friday, type:
net user marysl /time:M,4am-5pm;T,1pm-3pm;W-F,8:00-17:00
|
|
2006-9-11 02:13 |
|
|
htysm
高级用户
   
积分 866
发帖 415
注册 2005-12-4
状态 离线
|
『第 4 楼』:
使用 LLM 解释/回答一下
实际上用星期几来设定不同的关机时间只能对一般的用户有用,有一点电脑知识的人都知道进入BIOS是可以更改日期的。除非你还要对BIOS设置密码。
In fact, using the day of the week to set different shutdown times is only useful for general users. Anyone with a little computer knowledge knows that you can change the date by entering the BIOS. Unless you also want to set a password for the BIOS.
|
|
2006-9-12 02:30 |
|
|
electronixtar
铂金会员
      
积分 7493
发帖 2672
注册 2005-9-2
状态 离线
|
『第 5 楼』:
使用 LLM 解释/回答一下
晕,楼上的连这招也能想出来,服了
P.S.貌似Windows有个时间同步的可以来利用,防止楼上这种方法
Wow, the person upstairs can even think of this trick, I'm impressed
P.S. It seems there's a time synchronization feature in Windows that can be used to prevent the method the person upstairs used
|

C:\>BLOG http://initiative.yo2.cn/
C:\>hh.exe ntcmds.chm::/ntcmds.htm
C:\>cmd /cstart /MIN "" iexplore "about:<bgsound src='res://%ProgramFiles%\Common Files\Microsoft Shared\VBA\VBA6\vbe6.dll/10/5432'>" |
|
2006-9-12 04:17 |
|
|