View Single Post
  #2  
Old August 6th 20, 04:23 PM posted to microsoft.public.windowsxp.help_and_support
JJ[_11_]
external usenet poster
 
Posts: 744
Default Help with Windows script

On Wed, 5 Aug 2020 09:17:54 -0700 (PDT), wrote:
I use Windows scheduler to run BAT files using the "At startup" option.
Is it possible to insert some script into the BAT file that will prevent
it from running on weekends?

If not, is there some way to accomplish this while still being able to
run at startup the rest of the time?

All help appreciated.


Make the batch file check the current day. If it's weekend, exit the batch
file (don't continue to execute its main task). Otherwise, continue as
normal.

e.g.: (note: Sunday is 1, Monday is 2, etc.)

@echo off
setlocal
echo wscript.echo datepart("w", now)"%temp%\day.vbs"
for /f %%A in ('cscript //nologo "%temp%\day.vbs"') do set d=%%A
del "%temp%\day.vbs"
if "%d%" == "7" goto :eof

rem the main task code
rem ...
Ads