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 ]
```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 ]
