Iam getting syntax error when use sub under IF, please assist

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • khkrish
    New Member
    • Oct 2015
    • 2

    #1

    Iam getting syntax error when use sub under IF, please assist

    Code:
    EL_SUCCESS = 0
    
    EL_ERROR = 1
    
    EL_WARNING = 2
    
    EL_INFO = 4
    
    EL_AUDIT_SUCCESS = 8
    
    EL_AUDIT_FAILURE = 16
    Set WshShell = CreateObject("WScript.Shell") 
    
    set oFs = WScript.CreateObject("Scripting.FileSystemObject")
    set oDrives = oFs.Drives
    for each oDrive in oDrives
    if odrive.driveletter = "C" then
    percent_used_tmp= (oDrive.freeSpace /oDrive.TotalSize)*100
    res1=instr(percent_used_tmp,".")
    percent_used = Left(percent_used_tmp,res1 + 2)
    if percent_used < 100 then
    percent_used= 100 - percent_used
    end if
    if percent_used = 100 then 
    MsgBox " Please Check Drive Space."& vbcrlf & _
    " "& vbcrlf & _ 
    " WARNING!" & vbcrlf & _
    " You are out of disk space on the server! " & vbcrlf & _
    " You must delete unnecessary files" & vbcrlf & _ 
    " You are not able to save files on the server at this time.",48, "You are out of disk space on the server!"
    
    
    elseif percent_used > 85 then
    
    MsgBox " Please check Drive Space ."& vbcrlf & _
    " "& vbcrlf & _
    " WARNING!" & vbcrlf & _
    " You have utilized " & percent_used & "% of your allocated disk space on the server." & vbcrlf & _
    " You are not able to save files on the server at this time.",48, "You are out of disk space on the server!"
    
    WriteToEventLog EL_Warning, "successful..."
    
    sub WriteToEventLog(sLogEID,strELMessage)
    
    objShell.LogEvent sLogEID, strELMessage
    
    
    
    elseif percent_used < 85 then
    '*msgbox "it works",48, "Reminder"
    end if
    end if
    
    next
    Last edited by Rabbit; Oct 18 '15, 04:13 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.
  • khkrish
    New Member
    • Oct 2015
    • 2

    #2
    Im trying to log the message to windows event log, however iam getting syntax error when is inserted below lines in script

    Code:
    elseif percent_used > 20 then
    
    MsgBox " Please check Drive Space ."& vbcrlf & _
    " "& vbcrlf & _
    " WARNING!" & vbcrlf & _
    " You have utilized " & percent_used & "% of your allocated disk space on the server." & vbcrlf & _
    " You are not able to save files on the server at this time.",48, "You are out of disk space on the server!"
    
    WriteToEventLog EL_Warning, "successful..."
    
    sub WriteToEventLog(sLogEID,strELMessage)
    
    objShell.LogEvent sLogEID, strELMessage
    
    end sub
    Last edited by Rabbit; Oct 18 '15, 04:14 PM. Reason: Please use [code] and [/code] tags when posting code or formatted data.

    Comment

    • Rabbit
      Recognized Expert MVP
      • Jan 2007
      • 12517

      #3
      Please use code tags when posting code or formatted data.

      You can't start a sub within another sub. You need to end the other one first.

      Comment

      Working...