View Single Post
Old Jun 20th, 2008, 5:49 PM   #1
bscr
beginning netwrk *****
 
Join Date: Jun 2008
Posts: 1
Rep Power: 0 bscr is on a distinguished road
Question Batch file problems

Hi all!

Here is my problem: I'm trying to create a batch file that needs to needs to record the login and logoff times of users. This needs to be recorded between 5PM and 10 PM. At other times, no information needs to be gathered, just between those hours. Also, the file that is created will need to be deleted after a week.

What I have so far:

This batch file runs first:

::== 5to9.bat
@echo off
setLocal EnableDelayedExpansion
set run=n
for /f "tokens=1 delims=:" %%T in ('echo %TIME%') do (
set T=%%T
if !T! >17 set run=y
if !T! < 22 set run=y
)
if !run! ==y login.bat
::== DONE

After this is checked, this batch file should be triggered:

echo logon,User:,%username%,Computer:,%computername%,Date:,%date%,Time:,%time% >>C:\auditlog\%username%.csv

Here is the problem: The logging of the users runs by itself, but not when I run the first batch file.

Also, how would I go about adding code to delete the created file after a week?


Any help would be greatly appreciated!!


Stefan
bscr is offline   Reply With Quote