+ Post New Thread
Results 1 to 6 of 6
Scripts Thread, vbs overflow error in Coding and Web Development; 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 ...
  1. #1

    Join Date
    Mar 2007
    Posts
    1,748
    Thank Post
    79
    Thanked 288 Times in 219 Posts
    Rep Power
    70

    vbs overflow error

    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

  2. #2

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,859
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    182
    On which line does it overflow?

  3. #3

    SYNACK's Avatar
    Join Date
    Oct 2007
    Posts
    10,989
    Thank Post
    851
    Thanked 2,653 Times in 2,253 Posts
    Blog Entries
    9
    Rep Power
    764
    Have you made sure that none of the variables are ending up as zero?
    Overflow when trying to divide - ASP Free

  4. Thanks to SYNACK from:

    strawberry (4th September 2008)

  5. #4

    Join Date
    Mar 2007
    Posts
    1,748
    Thank Post
    79
    Thanked 288 Times in 219 Posts
    Rep Power
    70
    Quote Originally Posted by powdarrmonkey View Post
    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.

  6. #5

    powdarrmonkey's Avatar
    Join Date
    Feb 2008
    Location
    Alcester, Warwickshire
    Posts
    4,859
    Thank Post
    412
    Thanked 777 Times in 650 Posts
    Rep Power
    182
    You probably want a double-precision variable, not a single, but I don't know how to declare one in VB. In C it is just type double.

  7. #6

    Join Date
    Mar 2007
    Posts
    1,748
    Thank Post
    79
    Thanked 288 Times in 219 Posts
    Rep Power
    70
    found it, the / should have been \ . so it was returning zero

SHARE:
+ Post New Thread

Similar Threads

  1. VBS in Webpage help
    By DSapseid in forum Scripts
    Replies: 1
    Last Post: 4th July 2008, 11:53 PM
  2. .vbs .bat error in sysvol
    By alonebfg in forum Windows
    Replies: 7
    Last Post: 16th July 2007, 07:57 PM
  3. Would like to learn VBS
    By bishopsgarthstockton in forum Web Development
    Replies: 11
    Last Post: 12th July 2007, 07:44 AM
  4. ResetAccountsAdminSDHolder.vbs
    By meastaugh1 in forum Scripts
    Replies: 1
    Last Post: 5th February 2007, 11:52 AM
  5. VBS Tutorial
    By Nij.UK in forum Coding
    Replies: 15
    Last Post: 25th November 2006, 12:01 AM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •