Tha fact is that you want to use an advanced feature of date
command (Day Of Week) that Windows is unable to manage in DOS Batch.
For this, i would use a third party binary file date.exe
, that comes from Unix world and that works on Windows : UnxUtils (that is a collection of common GNU Unix utilities that runs on Windows).
Download it from here (UnxUtils.zip).
Then extract it, and delete all files except date.exe
Then, write a batch file like this (assuming date.exe
is located on c:\
) :
@ECHO OFF
REM Sunday is 0
for /f "delims=" %%a in ('c:\date.exe +%%w') do set DayOfWeek=%%a
if %DayOfWeek% == 0 (
cmd /c c:\path\to\exe\file.exe
) else (
echo Do Nothing
)
You can put it in the Windows startup folder and will work on all Windows version, regardless where you are in the world.
Also (much better), in those days, DOS Batch are a bit obsolete. As you are talking about Windows 8 i would consider Powershell (can be called by a batch file if needed) :
$a = Get-Date
if($a.DayOfWeek -eq "Sunday") {
cmd /c c:\path\to\exe\file.exe
}
Here, no need of third party binary file : Powershell is Powerfull ;)