Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Module Module1
- Public Sub Main()
- Application.Run(New Watchdog)
- End Sub
- End Module
- Public Class Watchdog
- Inherits ApplicationContext
- Private AppToWatch As String
- Private FullPath As String = "C:\path\2\file\malicious.exe"
- Private WithEvents P As Process
- Public Sub New()
- AppToWatch = System.IO.Path.GetFileNameWithoutExtension(FullPath)
- Dim PS() As Process = Process.GetProcessesByName(AppToWatch)
- If PS.Length = 0 Then
- StartIt()
- Else
- P = PS(0)
- P.EnableRaisingEvents = True
- End If
- End Sub
- Private Sub P_Exited(sender As Object, e As EventArgs) Handles P.Exited
- StartIt()
- End Sub
- Private Sub StartIt()
- P = Process.Start(FullPath)
- P.EnableRaisingEvents = True
- End Sub
- End Class
Add Comment
Please, Sign In to add comment