Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @echo off
- REM Establish path, directory, and file for Log
- Set "ProgLoc=%~dp0"
- IF Not Exist "%ProgLoc%\Logs" MD "%ProgLoc%\Logs"
- Set "LogDir=%ProgLoc%Logs"
- Set "Log_File=%LogDir%\LastRun.log"
- REM Use set substring modification to store runtime in variable
- Set "DT_String=%DATE:/=%_At_%TIME::=%"
- Set "DT_String=%DT_String:.=%"
- Set "DT_String=%DT_String: =0%"
- Set "DT_String=%DT_String:~4,16%"
- REM Function call in variable form
- Set "@_Track=Call :Track_Log"
- REM Overwrite last runtime log
- ECHO(Last Run # %DT_String%>"%Log_File%"
- GOTO :main
- REM Function to store the current Label in the Log using the @_Track variable macro and parameter.
- :Track_Log
- Echo(%1>>"%Log_File%"
- Exit /b
- REM The Below script is an Example of using the @_Track variable to store the current Label to the log.
- :first
- ECHO(Here
- %@_Track% first
- Exit /b
- :second
- ECHO(And
- %@_Track% second
- Exit /b
- :third
- ECHO(There
- %@_Track% third
- Exit /b
- :main
- For %%A IN (first,second,third) DO (
- CALL :%%A
- )
- TYPE "%Log_File%"
- Pause
Advertisement
Add Comment
Please, Sign In to add comment