Quantcast
Channel: THWACK: Popular Discussions - Script Lab
Viewing all articles
Browse latest Browse all 9937

Scripting a file count

$
0
0

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:

NDGet 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


Viewing all articles
Browse latest Browse all 9937

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>