checking hard drive levels 
Author Message
 checking hard drive levels

Everyone,

Does anyone know how to script a task that would check the hd level on a
remote server and when it reaches a certain level copies over folders/files
to another remote location?  Hope someone can help.

Thanks



Sun, 13 Feb 2005 03:39:18 GMT  
 checking hard drive levels

Quote:

> Everyone,

> Does anyone know how to script a task that would check the hd level
> on a remote server and when it reaches a certain level copies over
> folders/files to another remote location?  Hope someone can help.

set wmi = getobject("winmgmts:")
wql = "select deviceid, size, freespace from win32_logicaldisk where drivetype=3"
set results = wmi.execquery(wql)
for each drive in results
  with drive
    wscript.echo .deviceid, .size, .freespace, vbcrlf, _
      formatpercent((.size - .freespace)/.size,0) & " used"
  end with
next

Moving folders/files would require fso access via UNC paths to the hidden admin shares (C$, D$, etc.).  WMI doesn't support any file system i/o objects/methods.

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--



Sun, 13 Feb 2005 11:41:43 GMT  
 checking hard drive levels
This code gave info on my local hard drives, but not on any networked
drives.
How would this code need to be changed to get this info on all the mapped
drives too?
And UNC paths too?

-Paul Randall



Quote:

> Everyone,

> Does anyone know how to script a task that would check the hd level
> on a remote server and when it reaches a certain level copies over
> folders/files to another remote location?  Hope someone can help.

set wmi = getobject("winmgmts:")
wql = "select deviceid, size, freespace from win32_logicaldisk where
drivetype=3"
set results = wmi.execquery(wql)
for each drive in results
  with drive
    wscript.echo .deviceid, .size, .freespace, vbcrlf, _
      formatpercent((.size - .freespace)/.size,0) & " used"
  end with
next

Moving folders/files would require fso access via UNC paths to the hidden
admin shares (C$, D$, etc.).  WMI doesn't support any file system i/o
objects/methods.

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US
--



Mon, 14 Feb 2005 04:54:00 GMT  
 checking hard drive levels

Quote:

> This code gave info on my local hard drives, but not on any networked
> drives.
> How would this code need to be changed to get this info on all the mapped
> drives too?
> And UNC paths too?

Hi

Take a look at the property DriveType here:
http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_logicaldisk.asp

--
torgeir



Mon, 14 Feb 2005 05:08:08 GMT  
 checking hard drive levels


Quote:

> Take a look at the property DriveType here:
> http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_logicaldisk.asp

> --
> torgeir

I've played with the other drive types:
Value Meaning
0 Unknown
1 No Root Directory
2 Removable Disk
3 Local Disk
4 Network Drive
5 Compact Disc
6 RAM Disk

The Removable Disk value causes a problem if there is no floppy in a floppy
drive.  The percent formatting causes an error.
The network drive value causes the same error if a CD drive is networked and
has no CD inserted.
The compact disk value causes an error when .size is referenced, with or
without a CD in the first CD Drive.
But maybe I have an old version of WMI.
Anyhow, thanks for showing me the way to get info on all the drives.

Can WMI get the URL properties of cookies and temporary internet files?

-Paul Randall



Mon, 14 Feb 2005 07:03:42 GMT  
 checking hard drive levels

Quote:



> > Take a look at the property DriveType here:
> > http://msdn.microsoft.com/library/en-us/wmisdk/wmi/win32_logicaldisk.asp

> I've played with the other drive types:
> Value Meaning
> 0 Unknown
> 1 No Root Directory
> 2 Removable Disk
> 3 Local Disk
> 4 Network Drive
> 5 Compact Disc
> 6 RAM Disk

> The Removable Disk value causes a problem if there is no floppy in a floppy
> drive.  The percent formatting causes an error.
> The network drive value causes the same error if a CD drive is networked and
> has no CD inserted.
> The compact disk value causes an error when .size is referenced, with or
> without a CD in the first CD Drive.

In those cases, you need to error handle this yourself with On Error Resume Next
and test on the Error object.

Quote:
> But maybe I have an old version of WMI.

Not likely the case for the above.

Quote:
> Anyhow, thanks for showing me the way to get info on all the drives.

> Can WMI get the URL properties of cookies and temporary internet files?

I don't know.

--
torgeir



Mon, 14 Feb 2005 07:08:53 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. How to read the hard drives drive no.

2. Insert records from a database in floppy drive to hard drive

3. Hard Drive Serial Number/Total Drive Size

4. Checking Whether Drive is a CD ROM Drive

5. Hard drive help needed

6. How do attach file from local hard drive

7. Iterating through all files on Hard drive

8. Desperarely seeking Hp5si Hard drives

9. Hard drive initialisation

10. Does GhostScript work on non-C: hard drive?

11. Search hard driveS for file help

12. Saving to the local hard drive

 

 
Powered by phpBB® Forum Software