This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Scripting a file count

Hello all, I'm rather knew to scripting and found this script here on thwack. I have been able to run this script from my Orion server but not through solarwinds as part of a template and am hoping you guys can point me in the right direction to remedy this. When i run this script i get this error:

Get Output Failed:C:\ProgramData\SolarWinds\Orion\temp\59b0ee4c-c168-4b19-bf0c-42749f2d64eb(1, 10) Microsoft VBScript compilation error: Expected end of statement.
Any thoughts? Here is the script i'm using:

' Script Name: FileCount.vbs

' Purpose: This script will return the number of files in a folder.

' Usage: cscript.exe  FileCount.vbs [pathToFiles]

' [pathToFiles] is Local or UNC Path

Option Explicit

On Error Resume Next

  Dim lstArgs, path, fso, objDir, objFiles

  Set lstArgs = WScript.Arguments

  If lstArgs.Count = 1 Then

     path       = Trim( lstArgs( 0 ))

  Else

     WScript.Echo "Message: Usage: wscript.exe filelist.vbs [pathToFiles]" &vbCRLF &"[pathToFiles] Local or UNC Path"

     WScript.Echo "Statistic: 0"

     WScript.Quit( 1 )

  End If

  Set fso  = Wscript.CreateObject( "Scripting.FileSystemObject" )

 

  If fso.FolderExists( path ) Then

    Set objDir   = fso.GetFolder( path )

    If( IsEmpty( objDir ) = True ) Then

      WScript.Echo "Message: OBJECT NOT INITIALIZED"

      WScript.Echo "Statistic: 0"

      WScript.Quit( 1 )

    End If

   

    Set objFiles = objDir.Files

    

    If( IsEmpty( objFiles ) = True ) Then

      WScript.Echo "Message: OBJECT NOT INITIALIZED"

      WScript.Echo "Statistic: 0"

      WScript.Quit( 1 )

    End If

    WScript.Echo "Message: " & CInt( objFiles.Count ) & " FILES"

    WScript.Echo "Statistic: " & CInt( objFiles.Count )

    WScript.Quit( 0 )

   

  Else

    WScript.Echo( "Message: FOLDER NOT FOUND" )

    WScript.Echo "Statistic: 0"

    WScript.Quit( 1 )

  End If

Parents Reply Children
No Data