Guest User

Watchdogg

a guest
May 21st, 2016
464
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. Module Module1
  2.  
  3. Public Sub Main()
  4. Application.Run(New Watchdog)
  5. End Sub
  6.  
  7. End Module
  8.  
  9. Public Class Watchdog
  10. Inherits ApplicationContext
  11.  
  12. Private AppToWatch As String
  13. Private FullPath As String = "C:\path\2\file\malicious.exe"
  14.  
  15. Private WithEvents P As Process
  16.  
  17. Public Sub New()
  18. AppToWatch = System.IO.Path.GetFileNameWithoutExtension(FullPath)
  19. Dim PS() As Process = Process.GetProcessesByName(AppToWatch)
  20. If PS.Length = 0 Then
  21. StartIt()
  22. Else
  23. P = PS(0)
  24. P.EnableRaisingEvents = True
  25. End If
  26. End Sub
  27.  
  28. Private Sub P_Exited(sender As Object, e As EventArgs) Handles P.Exited
  29. StartIt()
  30. End Sub
  31.  
  32. Private Sub StartIt()
  33. P = Process.Start(FullPath)
  34. P.EnableRaisingEvents = True
  35. End Sub
  36. End Class
Add Comment
Please, Sign In to add comment