SHARE
TWEET

Watchdogg

a guest May 21st, 2016 240 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top