Search code examples
batch-filetimer

A batch file that run a program on a specific date and time and year


At our school, we prevent users from using notepad. But we would like to create a batch file, that we will install in start up to run notepad.exe on a specific date and time, each month. It may be each 5th January and each 5th February 2016. The batch file, once run, may execute the notepad.exe on each 5th January. We have tried with code below, but it's not working. We need some help please.

@echo off
:finddate
if %date% GEQ 29/12/2015 goto start
goto finddate

:start
start Notepad.exe
goto end
:end

Solution

  • Have you tried to use vbscript?

    Dim objShell
    Set objShell = WScript.CreateObject( "WScript.Shell" )
    Dim dt
    dt=now
    if (day(dt) = 5 and month(dt) = 1) Then
        objShell.Run(chr(34)&"C:\Program Files\Notepad.exe"&chr(34))
    End If
    Set objShell = Nothing