Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for vbsedver.vbs

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

  1. Option Explicit
  2.  
  3. If WScript.Arguments.Count > 0 Then Syntax
  4.  
  5. WScript.Echo "Latest version of VBSEdit: " & GetVBSEditVersion( )
  6.  
  7.  
  8. Function GetVBSEditVersion( )
  9. ' This function returns the latest VBSEdit version
  10. ' as string by reading Adersoft's download page.
  11. ' If an error occurs, the returned version will be "0".
  12. ' Written by Rob van der Woude
  13. ' http://www.robvanderwoude.com
  14. 	Dim objHTTP, objMatch, objRE, strHTML, strUserAgent, strVersion
  15. 	' Initial return string, in case an error occurs
  16. 	strVersion = "0"
  17. 	' Use WinHTTP to read the text from Adersoft's download page
  18. 	Set objHTTP = CreateObject( "WinHttp.WinHttpRequest.5.1" )
  19. 	objHTTP.Open "GET", "http://www.vbsedit.com/", False
  20. 	strUserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3"
  21. 	objHTTP.SetRequestHeader "UserAgent", strUserAgent
  22. 	objHTTP.Send
  23. 	If objHTTP.Status = 200 Then
  24. 		' If the page was returned, use a regular expression
  25. 		' to extract Foxit Reader's current version number
  26. 		strHTML = objHTTP.ResponseText
  27. 		Set objRE = New RegExp
  28. 		objRE.Pattern = "Version ([0-9]+(\.[0-9]+)+)"
  29. 		objRE.IgnoreCase = False
  30. 		objRE.Global = True
  31. 		Set objMatch = objRE.Execute( strHTML )
  32. 		If objMatch.Count > 0 Then
  33. 			strVersion = objMatch.Item(0).Submatches.Item(0)
  34. 		End If
  35. 		Set objMatch = Nothing
  36. 		Set objRE = Nothing
  37. 	End If
  38. 	Set objHTTP = Nothing
  39. 	' Return the result
  40. 	GetVBSEditVersion = strVersion
  41. End Function
  42.  
  43.  
  44. Sub Syntax
  45. 	Dim strMsg
  46. 	strMsg = "VBSEdVer.vbs,  Version 1.01" _
  47. 	       & vbCrLf _
  48. 	       & "Read the latest available version of VBSEdit from its download page" _
  49. 	       & vbCrLf & vbCrLf _
  50. 	       & "Usage  :  VBSEDVER.VBS" _
  51. 	       & vbCrLf & vbCrLf
  52. 	strMsg = strMsg & "Returns:  " & GetVBSEditVersion( ) & vbCrLf & vbCrLf
  53. 	strMsg = strMsg _
  54. 	       & "Note   :  This is a demo script, hardcoded for VBSEdit." _
  55. 	       & vbCrLf _
  56. 	       & "          You are encouraged to modify the code to your own requirements." _
  57. 	       & vbCrLf & vbCrLf _
  58. 	       & "Written by Rob van der Woude" _
  59. 	       & vbCrLf _
  60. 	       & "http://www.robvanderwoude.com"
  61. 	WScript.Echo strMsg
  62. 	WScript.Quit 1
  63. End Sub
  64.  

page last uploaded: 2017-08-21, 14:26