2
Answers

Kill Process from task manager

I did a project in vb.net, 3.5 framework using Visual Studio 2008.My Question is regarding killing the process from task manager. Whenever I am exiting my application by the Close button ('X') or an Exit button (P.S here 'Exit' is a button in the windows application) the process exists in the task manager and I had to remove it manually. I don't want to do that. The name of the process is iMaxAutotech.exe. I have used this code under form_closing event and in the exit button but it's not working ..grrh!!!

Under Exit Button :

Private Sub Exit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Dim mresult As MsgBoxResult
        mresult = MsgBox("Are you sure you want to exit?", MsgBoxStyle.YesNo)
        If mresult = MsgBoxResult.Yes Then
            Me.Close()
        End If
        Dim plist As Process() = Process.GetProcesses()
        For Each p As Process In plist
            Try
                If p.MainModule.ModuleName.ToUpper() = "iMaxAutotech.exe" Then p.Kill()
            Catch
                'seems listing modules for some processes fails, so better ignore any exceptions here
            End Try
        Next p
    End Sub

and in the Form Closing Event :

Private Sub Form3_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
        Dim plist As Process() = Process.GetProcesses()
        For Each p As Process In plist
            Try
                If p.MainModule.ModuleName.ToUpper() = "iMaxAutotech.exe" Then p.Kill()
            Catch
                'seems listing modules for some processes fails, so better ignore any exceptions here
            End Try
        Next p
    End Sub


I want the vb.net code for that,can any1 help me plz plz.It's very urgent ...Thanks in advance
Answers (2)
0
naura pax
NA 1.9k 64.8k 15y

hi Pankaj,
if you are creating dynamic query then at the time of creating sql string you can do following example :
 wherestring+=txt.Replace("'","''"); 
// single quote is passed string in
//first parameter and single quote is written twice '' for second.
Accepted
0
Master  Billa
NA 2.7k 0 15y
Hi

when you are use the single quite you need add extra two quote to string.or else is make to sql injection.

About this please take look,

http://archives.devshed.com/forums/windows-107/sql-injecttion-401471.html

thank you


0
Pankaj Singh
NA 69 0 15y
Thanks
0
Pankaj Singh
NA 69 0 15y
Thanks
0
Kirtan Patel
NA 35k 2.8m 15y
Hi you just need to Replace every Single timeWriten Quote to Double Time

suppose you are inserting

string " pankaj's Name "


then you should write String Like

"Pankaj' 's name "     { Dobule time Single Quotes before 's' )

Thats it :)

Better to Write Function That Will Replace Every Single Time Quote to Write it Double time in String


public string CSQ(string str)
{
 
    return Strings.Replace(str, "'", "''");
}



if i Helps you please check "Do you like this answer"






0
jinge
NA 2.4k 23.5k 15y