Script to Send Email If Network Drive Low on Disk Space

B

basis_consultant

Hi,

I would greatly appreciate it if somebody can send me a script (Or a
link to
one) for a procedure in XP that will check a network drive (Say mapped
as \\server\share locally to Z:) for a specified amount of disk space
(Can be hard-coded) and send an email if the amount of free disk
space is less than the threshhold.

I use blat for email, but I can adapt a script that uses another email
command.


Thanks,QZ
 
P

Pegasus [MVP]

Hi,

I would greatly appreciate it if somebody can send me a script (Or a
link to
one) for a procedure in XP that will check a network drive (Say mapped
as \\server\share locally to Z:) for a specified amount of disk space
(Can be hard-coded) and send an email if the amount of free disk
space is less than the threshhold.

I use blat for email, but I can adapt a script that uses another email
command.


Thanks,QZ

Here you go:
[1] @echo off
[2] set Limit=10000
[3] set Drive=E:
[4]
[5] for /F "tokens=3" %%a in ('dir %Drive%\ /-c ^| find /i "bytes free"') do
set FreeBytes=%%a
[6] set FreeMBytes=%FreeBytes:~0,-6%
[7] if "%FreeMBytes%"=="" set FreeMBytes=0
[8] if %FreeMBytes% LSS %Limit% echo blat /.. /..

Please note:
- Do not retype the code - use copy & paste instead.
- Set the Limit in MBytes
- You could do the whole job with a VB Script but it would take about four
times as much code.
 
B

basis_consultant

Hi Pegasus,

Thanks for taking the time to answer this question.
I copied an existing *.bat file, removed its contents and copied the
script to it,
but it indicated that the syntax of the command was incorrect.
Also, do I remove [1], [2], etc...
To what do I copy and paste your script?


Thanks,
QZ



I would greatly appreciate it if somebody can send me a script (Or a
link to
one) for a procedure in XP that will check a network drive (Say mapped
as \\server\share locally to Z:) for a specified amount of disk space
(Can be hard-coded) and send an email if the amount of free disk
space is less than the threshhold.
I use blat for email, but I can adapt a script that uses another email
command.
Thanks,QZ

Here you go:
[1] @echo off
[2] set Limit=10000
[3] set Drive=E:
[4]
[5] for /F "tokens=3" %%a in ('dir %Drive%\ /-c ^| find /i "bytes free"') do
set FreeBytes=%%a
[6] set FreeMBytes=%FreeBytes:~0,-6%
[7] if "%FreeMBytes%"=="" set FreeMBytes=0
[8] if %FreeMBytes% LSS %Limit% echo blat /.. /..

Please note:
- Do not retype the code - use copy & paste instead.
- Set the Limit in MBytes
- You could do the whole job with a VB Script but it would take about four
times as much code.
 
P

Pegasus [MVP]

Hi Pegasus,

Thanks for taking the time to answer this question.
I copied an existing *.bat file, removed its contents and copied the
script to it,
but it indicated that the syntax of the command was incorrect.
Also, do I remove [1], [2], etc...
To what do I copy and paste your script?

Thanks,
QZ

================

The line numbers are there for your guidance only and to allow you to unwrap
lines that your newsreader might have wrapped around. You MUST remove each
and every one of them.

You can save the code into any file with a .bat extension, e.g. into
c:\supercalifragilisticexpialidocious.bat. When it works then you should use
the Task Scheduler to run it once or twice each day. Remember to test it
under the Task Scheduler!
 
P

Pegasus [MVP]

How do you specify what the threshold for it to trigger the message? Is
it in bytes, kilobytes, megabytes, or gigabytes?

Have another look at my response to the OP. It clearly states the unit I
used for the limit.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top