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:
' 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