PC Review


Reply
Thread Tools Rate Thread

automated script of defrag question

 
 
Nathan H
Guest
Posts: n/a
 
      15th Sep 2004
Hi all

I'm trying to create a batch script on Windows Server 2003 (commands should
be relevent to 2000 also) that:

- cleans up any temp files
- analyzes a partition and records the info to a log file
- checks the created log file to see whether defrag needs to take place

The 3rd point is the problem I have.

I've managed to output defrag's analyze report but I'm having trouble
finding
a command that allows me to check that log file for the word "should" and
then
base an outcome if it finds it i.e.

output.log -----> "Should" ---> Yes ----> Run defrag
----> No -----> Finish

Hope that makes sense.

Any one have any ideas?

I've tried using FINDSTR but all I can get is it repeating the line
"should" was in and I cant think how to include it in a If & GOTO
routine.

Many Thanks,

--
Nathan Harmsworth
IT / Network Administrator
Ysgol Bro Ddyfi (Edu)


 
Reply With Quote
 
 
 
 
Matthias Tacke
Guest
Posts: n/a
 
      15th Sep 2004
"Nathan H" wrote:
>Hi all

Hi Nathan.
<snip>
>I've tried using FINDSTR but all I can get is it repeating the line
>"should" was in and I cant think how to include it in a If & GOTO
>routine.
>


find /I "should" <output.log||echo No defrag &goto :nodefrag
echo do defrag

a second way

set "Cnt=0"
for /F %%A ('find /I /C "should" ^<output.log') do set Cnt=%%A
if %Cnt% GEQ 1 (
echo do defrag
) else (
echo no defrag
)

HTH
--
Greetings
Matthias________________________________________
For help on nt commands enter in a cmd window:
W2K>HH windows.chm::ntcmds.htm XP>HH ntcmds.chm
 
Reply With Quote
 
David Candy
Guest
Posts: n/a
 
      15th Sep 2004
¦Find's exit codes
¦The following list shows each exit code and a brief description of its
¦meaning:
¦
¦0
¦ The search was completed successfully and at least one match was found.
¦
¦1
¦ The search was completed successfully, but no matches were found.
¦
¦2
¦ The search was not completed successfully. In this case, an error
¦ occurred during the search, and FIND cannot report whether any matches
¦ were found.
¦
¦You can use the ERRORLEVEL parameter on the <If> command line in a batch
¦program to process exit codes returned by FIND.

--
----------------------------------------------------------
War on the Pachyderms Terrorists
http://www.counterpunch.org/wilson09012004.html
"Nathan H" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Hi all
>
> I'm trying to create a batch script on Windows Server 2003 (commands should
> be relevent to 2000 also) that:
>
> - cleans up any temp files
> - analyzes a partition and records the info to a log file
> - checks the created log file to see whether defrag needs to take place
>
> The 3rd point is the problem I have.
>
> I've managed to output defrag's analyze report but I'm having trouble
> finding
> a command that allows me to check that log file for the word "should" and
> then
> base an outcome if it finds it i.e.
>
> output.log -----> "Should" ---> Yes ----> Run defrag
> ----> No -----> Finish
>
> Hope that makes sense.
>
> Any one have any ideas?
>
> I've tried using FINDSTR but all I can get is it repeating the line
> "should" was in and I cant think how to include it in a If & GOTO
> routine.
>
> Many Thanks,
>
> --
> Nathan Harmsworth
> IT / Network Administrator
> Ysgol Bro Ddyfi (Edu)
>
>

 
Reply With Quote
 
Nathan H
Guest
Posts: n/a
 
      15th Sep 2004
Hi David

¦Find's exit codes

That was just what I was after....



Is there a good way of finding EXIT codes - I've been to a few well known
websites
regarding batch files and they have some of the EXIT codes, but is there a
really good
source that you know of?

Many regards to you (and Mattias) for your suggestions & help,
Nathan H.


 
Reply With Quote
 
David Candy
Guest
Posts: n/a
 
      16th Sep 2004
Dos 6.22 help file (as XP's dos commands are Dos 5), XP's help file (for NT commands). These are the only places I know of them being listed.

--
----------------------------------------------------------
War on the Pachyderms Terrorists
http://www.counterpunch.org/wilson09012004.html
"Nathan H" <(E-Mail Removed)> wrote in message news:(E-Mail Removed)...
> Hi David
>
> ¦Find's exit codes
>
> That was just what I was after....
>
>
>
> Is there a good way of finding EXIT codes - I've been to a few well known
> websites
> regarding batch files and they have some of the EXIT codes, but is there a
> really good
> source that you know of?
>
> Many regards to you (and Mattias) for your suggestions & help,
> Nathan H.
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
automated script James Windows XP Configuration 1 15th May 2008 03:13 AM
Automated Process--VB Script Macro =?Utf-8?B?ZXJpa19ncmVnb3J5?= Microsoft Word Document Management 3 6th Jan 2006 03:31 AM
automated defrag =?Utf-8?B?TWFyYw==?= Windows XP General 13 1st Jun 2005 10:32 AM
Defrag and Disk Cleanup Utils automated in Task Scheduler =?Utf-8?B?SmFzb24gQmVubmV0dA==?= Windows XP Performance 2 14th Jan 2004 05:57 AM
Re: Automated Defrag Question David Candy Windows XP Performance 0 11th Jul 2003 03:19 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:27 AM.