UnhappyKill

Posts 1–5 of 5 · Page 1 of 1
Kill
hi i want kill in vb.net Lol.bat i tried this code and some more code but it doesnt works :
Code:
Public Shared Function killMyFile(ByVal procName As String, Optional ByVal all As Boolean = True) As Boolean
        Dim val As Boolean = False
        For Each procInstance As Process In Process.GetProcesses
            If procInstance.ProcessName.ToLower = procName.ToLower Then
                procInstance.Kill()
                val = True
                If Not all Then Exit For
            End If
        Next
        Return val
    End Function
Code:
killMyFile("MyFile.bat")
Here is what I made:


Also, remember that you don't add the file extension. (like: .bat)

Else your code might work, if you just do: (Removed: killMyFile("MyFile.bat") )
Code:
killMyFile("MyFile")
EDIT:
Whit my code, you can only use 1 process at the time, since it would replace the MyProc
Just as a "warning" in case you didn't know
Quote Originally Posted by Jorndel View Post
Here is what I made:


Also, remember that you don't add the file extension. (like: .bat)

Else your code might work, if you just do: (Removed: killMyFile("MyFile.bat") )
Code:
killMyFile("MyFile")
EDIT:
Whit my code, you can only use 1 process at the time, since it would replace the MyProc
Just as a "warning" in case you didn't know
Myproc.KIll , i get error whit this ?
Quote Originally Posted by tynab View Post
Myproc.KIll , i get error whit this ?
No, just make sure you type just like the code shows.
I have tested it so
Quote Originally Posted by Jorndel View Post
No, just make sure you type just like the code shows.
I have tested it so
lol i get error ? can you upload project please ?

---------- Post added at 04:15 AM ---------- Previous post was at 04:10 AM ----------

Quote Originally Posted by Jorndel View Post
No, just make sure you type just like the code shows.
I have tested it so
Thank you but i found out how to kill it
Code:
Dim pProcess() As Process = System.Diagnostics.Process.GetProcessesByName("cmd")

        For Each p As Process In pProcess
            p.Kill()
        Next
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us