Dim fs 'As Scripting.FileSystemObject
Dim wsh 'As WScript.Shell
Dim strFile 'As String
Dim strOperator 'As String
Dim lngSize 'As Long
Dim intReturn 'As Integer
Set fs = CreateObject("Scripting.FileSystemObject")
Set wsh = CreateObject("WScript.Shell")

'Count arguments
If Wscript.Arguments.Count <> 3 Then
	wsh.Popup "You must supply three arguments -- a file name, a comparison operator, and a size:" & vbCrLf & "start /w  " & Wscript.ScriptFullName &  "  ""C:\autoexec.bat""  "">""  ""1000""" & vbCrLf & "This script will return an errorlevel of 0 if your statement is true, 1 if false, 2 if in error." & vbCrLf &  "NOTE: You must always quote the operator. You only need to quote the file name only if it has spaces. You never need to quote the size (but you can if you want).", 20, "Error"
	Select Case Wscript.Arguments.Count
		Case 0
			'Do nothing. We already gave a good error message!
		Case 1
			wsh.Popup "The one argument you supplied was:" & vbCrLf & Wscript.Arguments(0), 5, "Error"
		Case 2
			wsh.Popup "The two arguments you supplied were:" & vbCrLf & Wscript.Arguments(0) & vbCrLf & Wscript.Arguments(1), 5, "Error"
		Case Else
			wsh.Popup "You supplied four or more arguments. Only the first four are displayed here:"  & vbCrLf & Wscript.Arguments(0) & vbCrLf & Wscript.Arguments(1) & vbCrLf & Wscript.Arguments(2) & vbCrLf & Wscript.Arguments(3), 5, "Error"
	End Select
	Wscript.Quit 2
End If

'Get arguments
strFile = Wscript.Arguments(0)
strOperator = Wscript.Arguments(1)
lngSize = Wscript.Arguments(2)

'Check arguments
If Not fs.FileExists(strFile) Then
	wsh.Popup """" & strFile & """ does not exist", 5, "Error"
	Wscript.Quit 2
End If
If Instr("> < >= <= =", strOperator) = 0 Then
	wsh.Popup "The operator you chose """ & strOperator & """ was not one of the allowed operators:" & vbCrLf & ">   <   =   >=   <=", 5, "Error"
	Wscript.Quit 2
End If
If Not IsNumeric(lngSize) Then
	wsh.Popup "The size value you entered """ & lngSize & """ is not a number.", 5, "Error"
	Wscript.Quit 2
End If

'Assume a false (errorlevel 1) return. We'll change it otherwise
intReturn = 1

'See if we can change it to true (rerrorlevel 0)
Select Case strOperator
	Case ">"
		If fs.GetFile(strFile).Size > Clng(lngSize) Then intReturn = 0
	Case "<"
		If fs.GetFile(strFile).Size < Clng(lngSize) Then intReturn = 0	
	Case "="
		If fs.GetFile(strFile).Size = Clng(lngSize) Then intReturn = 0 
	Case ">="
		If fs.GetFile(strFile).Size >= Clng(lngSize) Then intReturn = 0 
	Case "<="
		If fs.GetFile(strFile).Size <= Clng(lngSize) Then intReturn = 0 
	Case Else
		intReturn = 2
End Select

'All done. Return the errorlevel
Wscript.Quit intReturn