ajtsystems
IS-IT--Management
Hi I have written some code and need to know how to call some additional code if the space left on the disk is less than 10 percent. So far I can get the remainder of the disk in % but my bit where I say if remainder is less then 10% wscript.echo hello doesn't seem to work
Here is what I ave so far
remainder = "10.0%"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk Where DeviceID = 'C:'")
For Each objDisk in colDisks
intFreeSpace = objDisk.FreeSpace
intTotalSpace = objDisk.Size
pctFreeSpace = intFreeSpace / intTotalSpace
'Wscript.Echo formatpercent(pctFreeSpace)
actfreespace = formatpercent(pctFreeSpace)
wscript.echo actfreespace
if FormatPercent(pctFreeSpace) > remainder then
wscript.echo "hello"
end if
next
Here is what I ave so far
remainder = "10.0%"
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colDisks = objWMIService.ExecQuery _
("Select * from Win32_LogicalDisk Where DeviceID = 'C:'")
For Each objDisk in colDisks
intFreeSpace = objDisk.FreeSpace
intTotalSpace = objDisk.Size
pctFreeSpace = intFreeSpace / intTotalSpace
'Wscript.Echo formatpercent(pctFreeSpace)
actfreespace = formatpercent(pctFreeSpace)
wscript.echo actfreespace
if FormatPercent(pctFreeSpace) > remainder then
wscript.echo "hello"
end if
next