I hope you are ALL well and staying safe.
I have many Scripts that produce Reports, some single Scripts, and one that is menu driven and contains about 80+ Scripts. They ALL work great!
On ALL of them, I like to have the output include WeekDay DD-MMM-YYY HH:MM:SS. So the typical output would look like Created : Monday the 14-Feb-2022 at 21:01:32 for example.
With the menu driven Script, I usually open it in the morning and leave it open throughout the day, so in order to get it to show the correct output, regardless of when one of the Scripts within it is run during the day, I use the second Script.
::============================================================================================================================================
For a single Script that just gets run, I use the following . . .
Code: Select all
:: *** At the TOP of the 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")
set "DD=!LocalDateTime:~6,2!" & set /a "MMM=1!LocalDateTime:~4,2! - 100" & set "YYYY=!LocalDateTime:~0,4!"
set "HH=!LocalDateTime:~8,2!" & set "MM=!LocalDateTime:~10,2!" & set "SS=!LocalDateTime:~12,2!"
for /f "tokens=%MMM%" %%i in ("Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec") do set "Month=%%i"
set "Program_Date=!DD!-!Month!-!YYYY!
set "Created=!Week_Day! the !Program_Date! at !HH!:!MM!:!SS!"
:: *** Within the code . . . ***
echo Created : !Created!
Code: Select all
:: *** At the TOP of the 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")
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 "Program_Date=!DD!-!Month!-!YYYY!
:: *** Within the code . . . ***
Call :Report_Header
:: *** At the BOTTOM of the code . . . ***
:Report_Header
(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")
set "DD=!LocalDateTime:~6,2!" & set /a "MMM=1!LocalDateTime:~4,2! - 100" & set "YYYY=!LocalDateTime:~0,4!"
set "HH=!LocalDateTime:~8,2!" & set "MM=!LocalDateTime:~10,2!" & set "SS=!LocalDateTime:~12,2!"
set "Created=!Week_Day! the !Program_Date! at !HH!:!MM!:!SS!"
echo.
echo ======================================================================================================================================================================
echo Created : !Created!
) & Exit /b
For the second Script, there are duplicate lines/entries at the top and bottom, because this is the only way that I have found to get it to work, but I am sure that there must be an easier way?
The SECOND Script particularly is the main one that I would like help on please.
Any help will be greatly appreciated.