(view source code of login_log_access.bat as plain text)
:: Get current date in YYYYMMDD format if possible (XP Professional or later)
FOR /F "skip=1 tokens=1-3" %%A IN ('WMIC Path Win32_LocalTime Get Day^,Month^,Year /Format:Table') DO (
SET /A Today = 10000 * %%C + 100 * %%B + %%A
)
IF ERRORLEVEL 1 SET Today=
:: In case WMIC did not get the "sorted" date we'll have to get an "unsorted" date in regional date format
IF "%Today%"=="" (
REM Strip the leading day of the week from the date
FOR %%A IN (%Date%) DO SET Today=%%A
REM Remove the date delimiters
SET Today=%Today:/=%
SET Today=%Today:-=%
)
:: Create a directory for today if it does not exist
IF NOT EXIST \\Server\Logs\%Today% MD \\Server\Logs\%Today%
:: Log the computer name and the date and time in a file with the user's name
>> \\Server\Logs\%Today%\%UserName%.log ECHO %ComputerName%,%Date%,%Time%
page last modified: 2024-04-16; loaded in 0.0045 seconds