Dim fs 'As Scripting.FileSystemObject Dim wsh 'As WScript.Shell Dim strFile1, strOperator, strFile2 'As String 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 file name:" & vbCrLf & "start /w " & Wscript.ScriptFullName & " ""C:\autoexec.bat"" "">"" ""C:\config.sys""" & 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 names only if they have spaces.", 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 strFile1 = Wscript.Arguments(0) strOperator = Wscript.Arguments(1) strFile2 = Wscript.Arguments(2) 'Check arguments If Not fs.FileExists(strFile1) Then wsh.Popup """" & strFile1 & """ 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 fs.FileExists(strFile2) Then wsh.Popup """" & strFile2 & """ does not exist", 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(strFile1).DateLastModified > fs.GetFile(strFile2).DateLastModified Then intReturn = 0 Case "<" If fs.GetFile(strFile1).DateLastModified < fs.GetFile(strFile2).DateLastModified Then intReturn = 0 Case "=" If fs.GetFile(strFile1).DateLastModified = fs.GetFile(strFile2).DateLastModified Then intReturn = 0 Case ">=" If fs.GetFile(strFile1).DateLastModified >= fs.GetFile(strFile2).DateLastModified Then intReturn = 0 Case "<=" If fs.GetFile(strFile1).DateLastModified <= fs.GetFile(strFile2).DateLastModified Then intReturn = 0 Case Else intReturn = 2 End Select 'All done. Return the errorlevel Wscript.Quit intReturn