Prev | Current Page 534 | Next

John Paul Mueller

"Administering Windows Server 2008 Server Core"

TXT
REM Delete the temporary files.
@ECHO Removing the temporary files.
FOR /F ???delims==??? %%D IN (DeleteMe.TXT) DO Del ???%%D??? /Q > Errors.TXT
@ECHO Deletion of Temporary Files Completed!
@ECHO ON
This batch file uses three basic steps. First, it ensures that you??™ve defined a file that contains the
file extension specifications to delete. Second, it uses these file specifications to locate the files you
want to delete. Third, it deletes the file using the accumulated list of files. Notice that the batch file
automatically erases any old file lists before it begins generating the new one.
The trickiest piece of code in this example is the second FOR command. Notice the ???delims==???
entry. Because the DeleteMe.TXT file contains filenames with spaces, you need to use this option.
Otherwise, the FOR command only outputs the filenames up to the first space and the deletion will
fail. The batch file outputs any files that failed to delete to Errors.TXT, so you can check on them
later.
Once you create and fully test this batch file, you can create a second batch file for installing it
as a scheduled task on every machine on the network.


Pages:
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546
rehabilitacja w warszawie tonery konica konkurs mapa notebook toshiba tibia serwer