所以昨天我半複製/粘貼了一半這個批處理文件,根據星期幾來自動執行一些任務。它工作得很好,但今天停止了。它只是說,「回聲接通」,而不是寫在本週日的[1,7]整數控制檯上,昨天它做就好了... ...根據星期幾停止工作的批處理腳本
@echo off & Setlocal
Set "_=mon tues wed thurs fri sat sun"
For /f %%# In ('WMIC Path Win32_LocalTime Get DayOfWeek^|Findstr [1-7]') Do (
Set DOW=%%#)
:: Line below is supposed to write day of the week as [1,7] integer at the console. It did that and the rest worked fine yesterday, but not today.
echo %DOW%
pause
@echo off
IF %DOW%==1 (goto monday)
IF %DOW%==2 (goto tuesday)
IF %DOW%==3 (goto wednesday)
IF %DOW%==4 (goto thursday)
IF %DOW%==5 (goto friday)
IF %DOW%==6 (goto saturday)
IF %DOW%==7 (goto sunday)
goto finish
:monday
:: do something
goto finish
:tuesday
:: do something
goto finish
:wednesday
:: do something
goto finish
:thursday
:: do something
goto finish
:saturday
:: do something
goto finish
:sunday
:: do something
goto finish
:finish
echo finished running
我該如何解決這個問題?
它不是[1..7 ],但[0..6](其中0 =星期日)。星期天改變'findstr'和'if' – Stephan
它工作,但是如何?我使用非星期一作爲本週開始的非美國語言環境。這是否因計算機區域設置而改變? –
'wmic'輸出不依賴區域設置(可以很容易地編寫獨立於區域設置的代碼) – Stephan