|
-
Jun 15th, 2018, 06:00 AM
#1
Thread Starter
Member
Error: "Access to path 'xxx' is denied" when trying to end process from VB.Net
I have an Anti-Virus in VB.Net, which has a real-time protection engine. Here's how it works.
1. Any process that is opened, it gets scanned.
2. That process that gets scanned, gets its MD5 hash taken from it, then compared to a string of MD5 hashes.
3. If the hash from the process is the same, a MessageBox comes up saying and the program is SUPPOED TO automatically end the process when the MessageBox comes up, but, when I try to end it with code, it gives me an "'Access denied to path 'xxx'" error message.
This is my code for the function to end the program.
Code:
Private Function GetMD5String(ByVal strFilename As String) As String
Dim cMD5 = System.Security.Cryptography.MD5.Create
Dim bytHash As Byte()
Dim sb As New System.Text.StringBuilder
Dim scanbox As New TextBox
scanbox.Text = My.Computer.FileSystem.ReadAllText("viruslist.txt").ToString
Using cStream As New IO.FileStream(strFilename, IO.FileMode.Open, IO.FileAccess.Read, IO.FileShare.Read)
bytHash = cMD5.ComputeHash(cStream)
End Using
For Each c In bytHash
sb.Append(c.ToString("X2"))
Next
If scanbox.Text.Contains(sb.ToString) Then
Detect.Show()
Detect.BringToFront()
Me.SendToBack()
Kill(strFilename)
End If
Return sb.ToString
End Function
If I insert
Code:
Process.Kill(strFilename)
I get the error:
Too many arguments to 'Public Overloads Sub Kill()
I've run this program as administrator, but it still hasn't done anything.
Any help would be greatly appreciated! Thanks.
Last edited by Modulus; Jun 15th, 2018 at 06:12 AM.
Reason: not mentioning important information in question.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|