Downloads
23930.zip

I have a logon script to which I want to add code that checks the Modified date (e.g., 12/05/2001) of the workstation's virus-definition file (i.e., clean.dat) and sends a message to the systems administrator if the file needs updating. So far, I've successfully used the Dir command to obtain the file information and piped that output to the Find "/" command to single out the line with the date. However, the resulting string contains not only the date but also the time, file size, and filename. How can I extract the date from that string?

Using the For command is the best way to extract the date. As Listing 1 shows, you can use the For command with the /f switch to parse the string into smaller parts, or tokens. That way, you can select just the token that contains the Modified date. Then, you can compare the Modified date with the target date. If the Modified date isn't the same as the target date (02/25/2002 in Listing 1), you can use the Net Send command to send a message to the systems administrator's PC. For more information about how to use the For command with the /f switch, see "Shell Scripting 101, Lesson 8," http://www.winscriptingsolutions.com, InstantDoc ID 21984.