Solved exit bat file


junieman

Active member
Local time
2:40 PM
Posts
33
Visit site
OS
windows 11 pro
I have a bat file and would like to exit out of it if yesterday's date = SUNDAY OR SATURDAY.
Any other days the bat file would run correctly.
 

My Computer

System One

  • OS
    windows 11 pro
    Computer type
    PC/Desktop
    Manufacturer/Model
    dell
    CPU
    intel core i7-11700f
    Memory
    12 gb
    Monitor(s) Displays
    3
    Hard Drives
    256
    Keyboard
    wireless
    Mouse
    wireless
    Internet Speed
    50 mb
In the most general terms, you'd have to look for the DAY-DATA at the very first of the batch file and if it were Saturday or Sunday, then jump to END.
I've written b'zillions of batch files over the past 40 years or so, but I've never done exactly what you want to do.

I do believe it's possible to do what you want in DOS Batch File language, even though I can't give you the exact Syntax.

Good Luck,
TM :cool:
 

My Computer

System One

  • OS
    Win-11/Pro/64, Optimum 11 V5, 23H2 22631.3374
    Computer type
    PC/Desktop
    Manufacturer/Model
    Home Made w/Gigabyte mobo/DX-10
    CPU
    AMD FX 6350 Six Core
    Motherboard
    Gigabyte, DX-10, GA-78LMT-USB3
    Memory
    Crucial, 16 GB
    Graphics Card(s)
    NVIDEA GeForce 210, 1GB DDR3 Ram.
    Sound Card
    Onboard
    Monitor(s) Displays
    24" Acer
    Screen Resolution
    1280x800
    Hard Drives
    Crucial SSD 500GB, SanDisk 126GB SSD, Toshiba 1TB HD
    PSU
    EVGA 500 W.
    Case
    Pac Man, Mid Tower
    Cooling
    AMD/OEM
    Keyboard
    101 key, Backlit/ Mechanical Switches/
    Mouse
    Logitech USB Wireless M310
    Internet Speed
    Hughes Net speed varies with the weather
    Browser
    Firefox 64x
    Antivirus
    Windows Defender, Super Anti Spyware
    Other Info
    Given to me as DEAD, and irreparable.
    Rebuilt with Gigabyte mobo, AMD cpu, 16GB ram and 500GB Crucial SSD.
I have a bat file and would like to exit out of it if yesterday's date = SUNDAY OR SATURDAY.
Any other days the bat file would run correctly.
This might help

 

My Computer

System One

  • OS
    Windows 10 Pro + others in VHDs
    Computer type
    Laptop
    Manufacturer/Model
    ASUS Vivobook 14
    CPU
    I7
    Motherboard
    Yep, Laptop has one.
    Memory
    16 GB
    Graphics Card(s)
    Integrated Intel Iris XE
    Sound Card
    Realtek built in
    Monitor(s) Displays
    N/A
    Screen Resolution
    1920x1080
    Hard Drives
    1 TB Optane NVME SSD, 1 TB NVME SSD
    PSU
    Yep, got one
    Case
    Yep, got one
    Cooling
    Stella Artois
    Keyboard
    Built in
    Mouse
    Bluetooth , wired
    Internet Speed
    72 Mb/s :-(
    Browser
    Edge mostly
    Antivirus
    Defender
    Other Info
    TPM 2.0
I have a bat file and would like to exit out of it if yesterday's date = SUNDAY OR SATURDAY.
Any other days the bat file would run correctly.
Why not open Task Scheduler and Create a Task to run the batch file? In the settings for the Task, you can specify Monday to Friday (or NOT saturday or Sunday), and it will run at the time you set M-F, but not on Sa Su.
 

My Computers

System One System Two

  • OS
    11 Pro 23H2 22631.3593
    Computer type
    PC/Desktop
    Manufacturer/Model
    Lenovo ThinkCentre M920S SFF
    CPU
    i7-9700 @ 3.00GHz
    Motherboard
    Lenovo 3132
    Memory
    32GBDDR4 @ 2666MHz
    Graphics Card(s)
    Intel HD 630 Graphics onboard
    Sound Card
    Realtek HD Audio
    Monitor(s) Displays
    LG E2442
    Screen Resolution
    1920x1080
    Hard Drives
    1 x Samsung 970 EVO PLUS 500GB NVMe SSD, 1 x WD_BLACK SN770
    250GB NVMe SSD (OS and programs), 1 x WD_BLACK SN770
    500GB NVMe SSD (Data)
    Case
    Lenovo SFF
    Keyboard
    Cherry Stream TKL JK-8600US-2 Wired
    Mouse
    LogiTech M510 wireless
    Internet Speed
    Fast (for fixed wireless!)
    Browser
    Chrome, sometimes Firefox
    Antivirus
    Malwarebytes Premium & Defender (working together beautifully!)
  • Operating System
    11 Pro 23H2 22631.3593
    Computer type
    PC/Desktop
    Manufacturer/Model
    Lenovo ThinkCentre M920S SFF
    CPU
    i5-8400 @ 2.80GHz
    Motherboard
    Lenovo 3132
    Memory
    32GB DDR4 @ 2600MHz
    Graphics card(s)
    Intel HD 630 Graphics onboard
    Sound Card
    Realtek High Definition Audio onboard
    Monitor(s) Displays
    LG FULL HD (1920x1080@59Hz)
    Screen Resolution
    1920 x 1080
    Hard Drives
    1 x Samsung 970 EVO PLUS NVMe; 1 x Samsung 980 NVMe SSD
    Case
    Lenovo Think Centre SFF
    Mouse
    LogiTech M510 wireless
    Keyboard
    Cherry Stream TKL JK-8600US-2 Wired
    Internet Speed
    Fast (for fixed wireless!)
    Browser
    Chrome
    Antivirus
    Malwarebytes Premium and MS Defender, beautiful together
PowerShell can return DayofWeek as an integer.
0 = Sunday
1 = Monday
6 = Saturday

Code:
@echo off
powershell -nop "if ([int](Get-Date).DayOfWeek -le 1) { exit 1 }"

if %ERRORLEVEL% EQU 1 (
    @echo script exit
) else (
    @echo script continue
)
 

My Computer

System One

  • OS
    Windows 7
if yesterday's date = SUNDAY OR SATURDAY.
is that the same as todays date = Monday or Sunday
 

My Computers

System One System Two

  • OS
    Win7
    Computer type
    PC/Desktop
    CPU
    i5-8400
    Motherboard
    gigabyte b365m ds3h
    Memory
    2x8gb 3200mhz
    Monitor(s) Displays
    benq gw2480
    PSU
    bequiet pure power 11 400CM
    Cooling
    cryorig m9i
  • Operating System
    win7
    Computer type
    PC/Desktop
    CPU
    pentium g5400
    Motherboard
    gigabyte b365m ds3h
    Memory
    1x8gb 2400
    PSU
    xfx pro 450
Garlin,

Works great, thanks for the help.
 

My Computer

System One

  • OS
    windows 11 pro
    Computer type
    PC/Desktop
    Manufacturer/Model
    dell
    CPU
    intel core i7-11700f
    Memory
    12 gb
    Monitor(s) Displays
    3
    Hard Drives
    256
    Keyboard
    wireless
    Mouse
    wireless
    Internet Speed
    50 mb
This would be a batch way to do it, but I'm a PowerShell person myself.
Batch:
for /f %%a in ('date /t') do (
if "%%a" NEQ "Mon" (
  if "%%a" NEQ "Sat" (
    echo do something here
  )
)
)
 

My Computers

System One System Two

  • OS
    Windows 11 Pro 23H2 [rev. 3593]
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC12WSHi7
    CPU
    12th Gen Intel Core i7-1260P, 2100 MHz
    Motherboard
    NUC12WSBi7
    Memory
    64 GB
    Graphics Card(s)
    Intel Iris Xe
    Sound Card
    built-in Realtek HD audio
    Monitor(s) Displays
    Dell U3219Q
    Screen Resolution
    3840x2160 @ 60Hz
    Hard Drives
    Samsung SSD 990 PRO 1TB
    Keyboard
    CODE 104-Key Mechanical Keyboard with Cherry MX Clears
  • Operating System
    Linux Mint 21.2 (Cinnamon)
    Computer type
    PC/Desktop
    Manufacturer/Model
    Intel NUC8i5BEH
    CPU
    Intel Core i5-8259U CPU @ 2.30GHz
    Memory
    32 GB
    Graphics card(s)
    Iris Plus 655
    Keyboard
    CODE 104-Key Mechanical Keyboard - Cherry MX Clear

Latest Support Threads

Back
Top Bottom