#include <Misc.au3>

Func IsWannacryPatched()
   Local $sSrvFile = @WindowsDir & "\system32\drivers\srv.sys"
   Local $sSrvFileVersion = FileGetVersion($sSrvFile)
   Local $bResult = False
   ConsoleWrite ( "File path : " & $sSrvFile & @CRLF)
   ConsoleWrite ( "File version is : " & $sSrvFileVersion & @CRLF)

   if @OSVersion == "WIN_7" Then
      if _VersionCompare ( $sSrvFileVersion, "6.1.7601.23689" ) >= 0 Then
         $bResult =  True
      EndIf

   ElseIf @OSVersion == "WIN_XP" Then
      if _VersionCompare ( $sSrvFileVersion, "5.1.2600.7208" ) >= 0 Then
         $bResult =  True
      EndIf

   ElseIf @OSVersion == "WIN_2003" Then
      if _VersionCompare ( $sSrvFileVersion, "5.2.3790.6021" ) >= 0 Then
         $bResult =  True
      EndIf

   ElseIf @OSVersion == "WIN_2012" Then
      if _VersionCompare ( $sSrvFileVersion, "6.2.9200.22099" ) >= 0 Then
         $bResult =  True
      EndIf

   ElseIf @OSVersion == "WIN_2012R2" Then
      if _VersionCompare ( $sSrvFileVersion, "6.3.9600.18604" ) >= 0 Then
         $bResult =  True
      EndIf

   EndIf

   If $bResult ==  True Then
      ConsoleWrite ( "Wannacry Patched" & @CRLF)
   Else
      ConsoleWrite ( "Your operating system needs to be patched" & @CRLF & "For more information, visit https://technet.microsoft.com/en-us/library/security/ms17-010.aspx " & @CRLF )
   EndIf

   Return $bResult
EndFunc