New
#1
Batch Script does NOT Update Time
Good evening.
I have setup a Batch Script that I can run various Reports/Logs from. Now I have setup theWeek Day-Date-Time
output exactly how I want it and it works brilliantly. BUT, if I open the Batch Script and doNOT
run a Report/Log for say 30 minutes for example, when I do run a Report/Log, it shows the EXACT time that the Batch Script was opened, regardless of how many times I run it
I have tried usingsetlocal EnableDelayedExpansion
[!], and numerous other methods to get around this, but toNO
avail.
Here is the block of Batch Script in its raw form WITHOUT using ANYsetlocal EnableDelayedExpansion
to make it easier as a starting point . . .
Code:setlocal EnableDelayedExpansion for /f %%i in ('wmic OS Get LocalDateTime /Value ^& wmic Path Win32_LocalTime Get DayOfWeek /Value') do for /f %%j in ("%%i") do (set "%%j") & set /a "DOW=DayOfWeek+1" for /f "tokens=%DOW%" %%i in ("Sunday Monday Tuesday Wednesday Thursday Friday Saturday") do (set "Week_Day=%%i") for /f %%i in ('wmic OS Get LocalDateTime /format:list ^| find "="') do set "%%i" set "DD=%LocalDateTime:~6,2%" & set /a "MMM=1%LocalDateTime:~4,2% - 100" & set "YYYY=%LocalDateTime:~0,4%" for /f "tokens=%MMM%" %%i in ("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") do set "Month=%%i" set "HH=%LocalDateTime:~8,2%" & set "MM=%LocalDateTime:~10,2%" & set "SS=%LocalDateTime:~12,2%" set "Program_Date=%DD%-%Month%-%YYYY% set "Created_Date=%Week_Day% the %Program_Date% at %HH%:%MM%:%SS%"
The output is like this >Tuesday the 12-Oct-2021 at 20:24:45
for example.
I doNOT
want this to be in a DIFFERENT output format other that the above.
I want to do thisWITHOUT
using PowerShell.
This isNOT
a big problem, but it would be nice to find an answer for it.
Thanks in advance.