So here's Wat im trying to do
Ive got 2 List boxes 1 Shows Processes other one is for Storage
Anyway that's not important
Im trying to Kill all the Processes wat are stored in Listbox 2
I had to add .exe at List for Listbox 2
But still not working ???
The problem is its not removing the File names that are stored

ProgressBar1.Increment(1)
        Process.EnterDebugMode()
        If ProgressBar1.Value = ProgressBar1.Maximum Then  
            For Each proc In Form3.ListBox2.Items
                Dim ppdd() As Process = System.Diagnostics.Process.GetProcessesByName(proc.ToString)
                For Each p As Process In ppdd
                    p.EnterDebugMode()
                    p.Kill()
                    p.LeaveDebugMode()
                Next
            Next 
            Process.LeaveDebugMode()
            Timer2.Stop()
            MessageBox.Show("Removal was Succesfull", "Protocol Terminated", MessageBoxButtons.OK, MessageBoxIcon.Information)
            ProgressBar1.Value = 0
            Button4.Enabled = True
        End If

>>The problem is its not removing the File names that are stored
If it is for ListBox2, to have items removed, you need to loop backwards thru the ListBox and remove the .Items.

With ListBox2
            For i As Integer = .Items.Count - 1 To 0 Step -1
                .Items.Remove(.Items(i))
            Next
        End With

Looping forward and removing items will cause it to crash since it is looking for the .Count that was first set, and it constantly changes to .Count -=1.

Hope this helps.:)

commented: FU -2

:D No you are not understanding im not trying to remove Items From List box
Im trying to Loop through them so That They will be seen as a Process To Remove in Memorty
Its Kinda like a Storage to pick a process and save it then you can remove them

>>No you are not understanding...
My.Apologies?for not understanding and good.luck since I am out of possible suggestions/solutions regarding this thread.

No man its okay
Okay so Ive got it working but the Example very advanced
or doesnt really make much sense

For Each proc In Form3.ListBox2.Items
                Dim ppdd() As Process = System.Diagnostics.Process.GetProcessesByName(proc.ToString.ToLower.Split(".")(0))
                For Each p As Process In ppdd
                    p.Kill()
                Next
            Next

The

(proc.ToString.ToLower.Split(".")(0))

doesnt make sense why is it needed becuase Removing Normal Programs like this does not need the Backend

Dim BTProcess() As Process = System.Diagnostics.Process.GetProcessesByName("BtTray")
            For Each p As Process In BTProcess
                p.Kill()
            Next

:'(So please Codeorder Help Me

:'( I don't know how!!! :'(

I did however noticed that your are Dim 'ing inside a For/Next loop. From my perspective, I think that it is overworking someone's p.c. to the bone by constatly Dim 'ing something.
Why not Dim just before the For/Next and reuse that Variable in the loop, instead of constantly setting new Variables ?

Hope it helps.:)

Dude it works
I just dont understand how it works ????
:-O

THis Piece of Code is Not making sense but it does work i just wana understand how it Works

proc.ToString.ToLower.Split(".")(0))

:@

Post the code that loads the .Processes in your ListBox.
I'll use the code you currently have here and will try to "make sense" of how it works, then will post a possible "understand.Me.NT":D of how it works.:)

Okay Here it is. This is the file Where it is Stored and reads it

Dim WoofRead = New IO.StreamReader(MySettingfile)
            While (WoofRead.Peek() > -1)
                Form3.ListBox2.Items.Add(WoofRead.ReadLine)
            End While
            WoofRead.Close()

THis is the Process adder from listbox 1 to listbox 2(aka Storage(File))

Try
            ListBox2.Items.Add(ListBox1.SelectedItem.ToString & ".exe")
        Catch tt As Exception
        End Try

And Here i save the List box 2 Items To Storage File

If Me.CheckBox1.Checked Then
            Dim myCoolWriter As New IO.StreamWriter(MySettingfil)
            For i As Integer = 0 To ListBox2.Items.Count - 1
                myCoolWriter.WriteLine(ListBox2.Items(i).ToString)
            Next
            myCoolWriter.Close()
            Me.Dispose()
        Else
            Dim myCoolWriter As New IO.StreamWriter(MySettingfil)
            For i As Integer = 0 To ListBox2.Items.Count - 1
                myCoolWriter.WriteLine(ListBox2.Items(i).ToString)
            Next
            myCoolWriter.Close()
        End If

:-/Hope It Helps you to Understand I can also give the Project To you:S

;)But only the Build File not the code ....

Then Maybe You will Understand More Easily:)

Okay Ive got a New Problem When i load The Storage file Into Listbox 2 it adds Every item twice becuase i have to load the File in Form1 and Form 3 is there any workaround..

Here's the code

Dim WoofRead = New IO.StreamReader(MySettingfile)
            While (WoofRead.Peek() > -1)
                Form3.ListBox2.Items.Add(WoofRead.ReadLine)
            End While
            WoofRead.Close()

Okay Sory Here's updated code It's Working Now , atleast for now

ListBox2.Items.Clear()
        Dim WoofRead = New IO.StreamReader(MySettingfil)
        While (WoofRead.Peek() > -1)
            ListBox2.Items.Add(WoofRead.ReadLine)
        End While
        WoofRead.Close()

:D Sorry For asking my bad:D

I've been out all day, really tired, though I still noticed that you have not posted the code that loads the .Processes into your ListBox?

Since that was too much of a difficult task for you to do, even after 100+attempts of posting:D, why not just post one or 2 of the ListBox.Items(Processes) in your next post.

I mostly need to see how they are loaded into your ListBox, If FullPath, ElseIf only FileName, etc.. This because I am also a bit confused on how you can .Split by the "." and still get a For/Next loop out of one .Item(Process?).

Private Sub UpdateProcessList()
        ListBox1.Items.Clear()
        Dim p As System.Diagnostics.Process
        For Each p In System.Diagnostics.Process.GetProcesses()
            ListBox1.Items.Add(p.ProcessName)
        Next
        ListBox1.Sorted = True
        Label3.Text = "Processes : " & ListBox1.Items.Count.ToString
        Label4.Text = "Processes : " & ListBox2.Items.Count.ToString
    End Sub

Ill try not to use more space in the thread :D

No man its okay
Okay so Ive got it working but the Example very advanced
or doesnt really make much sense

For Each proc In Form3.ListBox2.Items
                Dim ppdd() As Process = System.Diagnostics.Process.GetProcessesByName(proc.ToString.ToLower.Split(".")(0))
                For Each p As Process In ppdd
                    p.Kill()
                Next
            Next

How exactly does this "work" w/your most recent posted.code, since I get no results from it?Not even a MsgBox instead of .Kill.

Okay im not sure what you really want
Do you want where i kill the process
Or do you want when I add Thee current processes from listbox 1 > 2
?????
:sweat:

>>Dude it works
>>I just dont understand how it works ????
<<How exactly does this "work" w/your most recent posted.code, since I get no results from it?

;)Okay im gonna attach My program so that you can see how it works:icon_mrgreen:

Thanks for the att.File, though I do not run uploaded.exe Files; especially If Not from a trusted.download sight as Download.com.
<<My.Apologies?
...again?

If you have any questions that you think I might be able to answer, do notify me.
As for me wasting My.time and getting nowhere, again, not hapenning "again". Good luck w/this thread, I am out of here.

I have a Problem with my Modified Event
As you can See !
i know My declarations are Private I tried Some thing still didn't work

So what i want to do as you can see is that if the save button was not clicked then
it would check if the listbox2 larger is than the myproccesesCurrentnumber
Then you see Msgbox's about saving bla bla bla
But Here's the problem if i open the Form again and close it again without making changes it would Pop up the Modified Event which it should not do since i never modified it so what gives !! why is this happening:|
Plus the declarations values are Restored as Normal each time on Form load so
it's not saving the values so how is this Possible :angry:

Private myprocessesCurrentNumber As Integer
Private CLickedSAvebuttonOnOpen As Integer
Private Sub Form3_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If Me.ListBox2.Items.Count > myprocessesCurrentNumber Then
            If CLickedSAvebuttonOnOpen = 0 Then
                If MessageBox.Show("<1> Storage / History Box Has been Modified and has not Been saved to History / Storage File !!!" & vbNewLine & "<2> Would you like to save The Modified Data?", "*Error - Not Saved*", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) = Windows.Forms.DialogResult.Yes Then
                    Button2.PerformClick()
                Else
                    MsgBox("Saved Option was Cancelled by User", MsgBoxStyle.Information, "Save Cancelled")
                End If
            Else
            End If
        Else
        End If
    End Sub
Private Sub Form3_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Timer1.Start()
        Timer2.Start()
        [B]myprocessesCurrentNumber = ListBox2.Items.Count <<<
        CLickedSAvebuttonOnOpen = 0 <<< [/B]
        ListBox1.ContextMenuStrip = ContextMenuStrip1
        ListBox2.ContextMenuStrip = ContextMenuStrip2
        UpdateProcessList()
        ListBox2.Items.Clear()
        Dim WoofRead = New IO.StreamReader(MySettingfil)
        While (WoofRead.Peek() > -1)
            ListBox2.Items.Add(WoofRead.ReadLine)
        End While
        WoofRead.Close()
    End Sub
Private Sub Save_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Try
           [B] CLickedSAvebuttonOnOpen = 1[/B] <<<
            If Me.CheckBox1.Checked Then
                Dim myCoolWriter As New IO.StreamWriter(MySettingfil)
                For i As Integer = 0 To ListBox2.Items.Count - 1
                    myCoolWriter.WriteLine(ListBox2.Items(i).ToString)
                Next
                myCoolWriter.Close()
                Me.Dispose()
            Else
                Dim myCoolWriter As New IO.StreamWriter(MySettingfil)
                For i As Integer = 0 To ListBox2.Items.Count - 1
                    myCoolWriter.WriteLine(ListBox2.Items(i).ToString)
                Next
                myCoolWriter.Close()
            End If
        Catch Save As Exception
        End Try
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.