Rob van der Woude's Scripting Pages
Powered by GeSHi

Source code for avver.kix

(view source code of avver.kix as plain text)

  1. ; AVVer.kix,  Version 1.05
  2. ; Checks the number of days passed since the last update of
  3. ; Symantec AntiVirus Corporate Edition 8's or Network Associates'
  4. ; McAfee 4 virus definitions and generates a message if it exceeds
  5. ; the specified limit.
  6. ;
  7. ; Usage:  KIX32  AVVER.KIX  [ $MaxDefAge=nn ]
  8. ;
  9. ; Where:  nn is the maximum time allowed since the last update
  10. ;
  11. ; Written by Rob van der Woude
  12. ; http://www.robvanderwoude.com
  13. ;
  14. ; Note:   This script and its author are in NO way associated
  15. ;         with neither Symantec nor Network Associates.
  16.  
  17.  
  18. ; Hide console window
  19. $x = SetConsole( "HIDE" )
  20.  
  21. ; Check if maximum virus definitions age
  22. ; is specified, otherwise use default value
  23. If $MaxDefAge = 0
  24. 	$MaxDefAge = 14
  25. EndIf
  26.  
  27. ; This registry key specifies the last update
  28. ; of the SAV virus definitions in hexadecimal
  29. $SAVRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Symantec\SharedDefs\DefWatch"
  30. $DefVer    = ReadValue( $SAVRegKey, "DefVersion" )
  31. If $DefVer
  32. 	; If the key has any value, Symantec AntiVirus
  33. 	; Corporate Edition is probably installed
  34. 	$AVType  = "SAV"
  35. 	$AVDescr = "Symantec AntiVirus Corporate Edition"
  36. 	; Extract the day, month & year of the last update
  37. 	$LastUpdYrX = "&" + SubStr( $DefVer, 3, 2 ) + SubStr( $DefVer, 1, 2 )
  38. 	$LastUpdYr  = Val( $LastUpdYrX )
  39. 	$LastUpdMnX = "&" + SubStr( $DefVer, 7, 2 ) + SubStr( $DefVer, 5, 2 )
  40. 	$LastUpdMn  = Val( $LastUpdMnX )
  41. 	$LastUpdDyX = "&" + SubStr( $DefVer, 15, 2 ) + SubStr( $DefVer, 13, 2 )
  42. 	$LastUpdDy  = Val( $LastUpdDyX )
  43. Else
  44. 	; Let's try if McAfee is installed.
  45. 	; This registry key specifies the last
  46. 	; update of the McAfee virus definitions
  47. 	$McARegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Network Associates\TVD\"
  48. 	$McARegKey = $McARegKey + "Shared Components\VirusScan Engine\4.0.xx"
  49. 	$EngineVer = ReadValue( $McARegKey, "szEngineVer" )
  50. 	If $EngineVer
  51. 		; If this registry key has any value
  52. 		; then McAfee is probably installed
  53. 		$AVType  = "McAfee"
  54. 		$AVDescr = "McAfee VirusScan"
  55. 		; Extract the day, month & year of the last update
  56. 		$DatDate   = ReadValue( $McARegKey, "szDatDate" )
  57. 		$DateArray = Split( "$DatDate", "/")
  58. 		For Each $Element In $DateArray
  59. 			Select
  60. 				Case $LastUpdDy
  61. 					$LastUpdYr = $Element
  62. 				Case $LastUpdMn
  63. 					$LastUpdDy = $Element
  64. 				Case 1
  65. 					$LastUpdMn = $Element
  66. 			EndSelect
  67. 		Next
  68. 	Else
  69. 		; We didn't find Symantec AntiVirus, nor McAfee ViruScan
  70. 		$Title = "AntiVirus"
  71. 		$Msg = "Neither Symantec nor McAfee AntiVirus are installed. "
  72. 		$Msg = $Msg + Chr(13) + Chr(10) + "Please contact your "
  73. 		$Msg = $Msg + "helpdesk for further instructions. "
  74. 		$x = MessageBox( $Msg, $Title, 64 )
  75. 		Quit 1
  76. 	EndIf
  77. EndIf
  78.  
  79. ; Calculate the total number of days between January
  80. ; 1st and the last update, ignoring leap years
  81. Select
  82. 	Case $LastUpdMn = 1
  83. 		$LastUpdTotDy =   0 + $LastUpdDy
  84. 	Case $LastUpdMn = 2
  85. 		$LastUpdTotDy =  31 + $LastUpdDy
  86. 	Case $LastUpdMn = 3
  87. 		$LastUpdTotDy =  59 + $LastUpdDy
  88. 	Case $LastUpdMn = 4
  89. 		$LastUpdTotDy =  90 + $LastUpdDy
  90. 	Case $LastUpdMn = 5
  91. 		$LastUpdTotDy = 120 + $LastUpdDy
  92. 	Case $LastUpdMn = 6
  93. 		$LastUpdTotDy = 151 + $LastUpdDy
  94. 	Case $LastUpdMn = 7
  95. 		$LastUpdTotDy = 181 + $LastUpdDy
  96. 	Case $LastUpdMn = 8
  97. 		$LastUpdTotDy = 212 + $LastUpdDy
  98. 	Case $LastUpdMn = 9
  99. 		$LastUpdTotDy = 243 + $LastUpdDy
  100. 	Case $LastUpdMn = 10
  101. 		$LastUpdTotDy = 273 + $LastUpdDy
  102. 	Case $LastUpdMn = 11
  103. 		$LastUpdTotDy = 304 + $LastUpdDy
  104. 	Case $LastUpdMn = 12
  105. 		$LastUpdTotDy = 334 + $LastUpdDy
  106. EndSelect
  107.  
  108. ; Calculate the number of days between today and the last update
  109. $DefsOld = ( 365 * ( @YEAR - $LastUpdYr ) ) + @YDAYNO - $LastUpdTotDy
  110.  
  111. ; Send a message to the user if the definitions are too old
  112. If $DefsOld > $MaxDefAge
  113. 	$Title = "$AVType"
  114. 	$Msg = "Your virus definitions are $DefsOld days old."
  115. 	$Msg = $Msg + Chr(13) + Chr(10) + "Please contact "
  116. 	$Msg = $Msg + "your helpdesk for further instructions. "
  117. 	$x = MessageBox( $Msg, $Title, 64 )
  118. EndIf
  119.  
  120. ; Show console window again
  121. $x = SetConsole( "SHOW" )
  122.  

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