Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for mdacver.vbs

(view source code of mdacver.vbs as plain text)

  1. Option Explicit
  2.  
  3. If WSCript.Arguments.Named.Count   > 0 Then Syntax
  4. If WSCript.Arguments.UnNamed.Count > 1 Then Syntax
  5.  
  6. Dim intRC, objConn
  7.  
  8. intRC = 0
  9.  
  10. ' Create a connection object
  11. Set objConn = CreateObject( "ADODB.Connection" )
  12.  
  13. ' If a minimum required version was specified, compare it to
  14. ' the actual version and return a non-zero return code if the
  15. ' required minimum wasn't met
  16. If WSCript.Arguments.UnNamed.Count = 1 Then
  17. 	If IsNumeric( WSCript.Arguments.UnNamed(0) ) Then
  18. 		If objConn.Version < WSCript.Arguments.UnNamed(0) Then
  19. 			intRC = 1
  20. 		End If
  21. 	Else
  22. 		Syntax
  23. 	End If
  24. End If
  25.  
  26. ' Display the (MDAC) version number
  27. WScript.Echo objConn.Version
  28.  
  29. Set objConn = Nothing
  30.  
  31. ' End the script, and return the result of the comparison
  32. WScript.Quit intRC
  33.  
  34.  
  35. Sub Syntax
  36. 	Dim strMsg
  37. 	strMsg = "MDACVer.vbs,  Version 1.00" _
  38. 	       & vbCrLf _
  39. 	       & "Check the installed MDAC version, and optionally compare it to a" _
  40. 	       & vbCrLf _
  41. 	       & "specified minimum required version number" _
  42. 	       & vbCrLf & vbCrLf _
  43. 	       & "Usage:  CSCRIPT.EXE  //NoLogo  mdacver.vbs  [ min_req ]" _
  44. 	       & vbCrLf & vbCrLf _
  45. 	       & "Where:  ""min_req""  is the minimum required version; the script will" _
  46. 	       & vbCrLf _
  47. 	       & "                   return a return code 1 if the actual MDAC version" _
  48. 	       & vbCrLf _
  49. 	       & "                   is older than the minimum specified, or 0 if it is" _
  50. 	       & vbCrLf _
  51. 	       & "                   equal or newer or if no minimum was specified." _
  52. 	       & vbCrLf & vbCrLf _
  53. 	       & "Written by Rob van der Woude" _
  54. 	       & vbCrLf _
  55. 	       & "http://www.robvanderwoude.com"
  56. 	WScript.Echo strMsg
  57. 	WScript.Quit 1
  58. End Sub
  59.  

page last modified: 2024-04-16; loaded in 0.0085 seconds