Jump to content

Recommended Posts

Posted

following script gives an overflow error, help!

---------------

On Error Resume Next

strComputer = "10.0.0.3"

MailServer="10.0.0.5"

Dim emailaddy

Dim holder

dim diskspace1

dim diskspace2

dim a

dim b

dim c

Dim objWMI : Set objWMI = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

 

strDrive = "Win32_LogicalDisk.DeviceID=" & chr(34) & "D:" & chr(34)

 

Set colQuotas = objWMI.ExecQuery ("Select * from Win32_DiskQuota Where QuotaVolume = '" & strDrive & "'")

 

For Each objQuota in colQuotas

 

If objQuota.Status=2 Then

 

diskspace1 = objQuota.DiskSpaceUsed\1000000

 

diskspace2 = objQuota.Limit\1000000

 

a = objQuota.DiskSpaceUsed

b = objQuota.Limit

c = (a - b) \1000000

 

 

holder = objQuota.User

holder = right(holder,len(holder)-40)

holder = left(holder,len(holder)-1)

 

 

Wscript.Echo " Mailing : " & emailaddy

Set objMessage = CreateObject("CDO.Message")

objMessage.Subject = "you have reached your Quota limit."

objMessage.From = "Quotacheck@***.co.uk"

objMessage.To = "*****"

objMessage.TextBody = "Hello, You have used all the diskspace afforded to your by your quota. Please consider removing some of the files you have placed on the network."

 

 

 

'==This section provides the configuration information for the remote SMTP server.

'==Normally you will only change the server name or IP.

objMessage.Configuration.Fields.Item _

("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

 

'Name or IP of Remote SMTP Server

objMessage.Configuration.Fields.Item _

("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "10.0.0.5"

 

'Server port (typically 25)

objMessage.Configuration.Fields.Item _

("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25

 

objMessage.Configuration.Fields.Update

 

'==End remote SMTP server configuration section==

 

objMessage.Send

 

else

END IF

Next

Posted
On which line does it overflow?

 

fairly sure its this one...

 

diskspace1 = objQuota.DiskSpaceUsed\1000000

 

it gives a huge number when it does, so i wonder if i need to declare the variable in a different way.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...