1.

Solve : Defragment batch file help plz!!?

Answer»

Hi guys and thanks in advance!

I'm trying to have the analysis of the c: DRIVE happen at startup and append the results in a txt FILE. My problem is creating a shutdown script that searches for a string in the txt that either says "You should defragment this volume" or "You do not need to defragment this volume" and then defrags when it needs to or not.

This is what I have for the startup analysis BATCH file which works perfectly fine:

    start /B /NORMAL defrag.exe c: -a -f >c:\defrag.txt

This is the batch file I have to run as a shutdown script which I can't seem to get to work.

    findstr "You should defragment this volume" "c:\defrag.txt"
    if errorlevel0 defrag.exe c: -f

What am I doing wrong?maybe you did this line wrong Code: [Select]if errorlevel0 defrag.exe c: -ftry that Code: [Select]if '%errorlevel%' equ '0' defrag.exe C:\ -fexcellent! thanks so much, this worked perfectly. =D



Discussion

No Comment Found