Question Locked

Logon Scripts for XP

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi, I am needing to create a script to be run on XP computers in our network, that will copy a file from one location to another location. But the big thing is that I only want the script to run on the users first log in of the day, not every time that they log in. If you have any idea of how to do this and can help me out that would be gret. Thanks.

Ross

3 replies

by Former member

The script wrote a short logfile with statistics from the copy. The script would first check the datestamp for the logfile. If the logfile had todays datestamp, then obviously the copy had already been performed that day, and the copy would be skipped.

by dumphrey

you could add an if statement that first checks the date stamp on the file and compares it to the current date, if they match, it does not copy, if the do not match, it copies the file.
*****BAT file Below****

@Echo Off

REM Sets variable for date in the mm/dd/yyyy
REM format

SET usedate=%DATE:~4,2%/%DATE:~7,2%/%DATE:~10,4%

REM checks for existance of the file desired
REM And copies output of DIR command
REM to a file called testcond.txt (makes a
REM logfile, overwritten each run)

dir c:\dir1\dir.txt /TA > c:\dir1\testcond.txt

REM looks in the logfile and looks for
REM todays date at the beginning of the
REM first text string

findstr "%USEDATE%" c:\dir1\testcond.txt

REM IF the dates of the files do not match
REM the file copies newfile.txt into
REM c:\dir1 and renames it dir.txt
REM thus overwritting the existing file

if "%errorlevel%" equ "1" (move c:\dir2\newfile.txt c:\dir1\dir.txt)

*****end batch file*****

this is a rough outline you can run with
just change paths and such, hope it helps.

This discussion is closed to new replies.