473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

WMI Win32_Process Terminate Method with Listbox

(Type your message here)

--------------------------------
From: Peter Neuburger

Hi Everybody,

I need some help with the WMI Terminate Method.

I have a Listbox where I get all the Process Information using the WMI Win32_process
class, that works fine.

Now I have a Stop Button that should terminate the process when I select it in the listbox
but I don?t really know how to write the Code, cause this don?t really work.

Code example:

Dim proc as ManagementClass("Win32_process")
Dim method() as Object = listbox1.items(listbox1.SelectedIndex), nothing)

try

if listbox1.SelectedIndex = -1 then
MessageBox.show ("Please select a Process")

else

proc.InvokeMethod("Terminate", method)

end if

Any Idea?s ???
thanks

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>foqnHOg7Vk2Mc1AVqDQLWQ==</Id>
Nov 20 '05 #1
3 5902
Alternately, you could use the System.Diagnostics.Process class, and call
either CloseMainWindows or Kill.
You can also use the same Process class to return a list of running
processes.

-Rob Teixeira [MVP]

"Peter Neuburger via .NET 247" <an*******@dotnet247.com> wrote in message
news:OH**************@TK2MSFTNGP10.phx.gbl...
(Type your message here)

--------------------------------
From: Peter Neuburger

Hi Everybody,

I need some help with the WMI Terminate Method.

I have a Listbox where I get all the Process Information using the WMI Win32_process class, that works fine.

Now I have a Stop Button that should terminate the process when I select it in the listbox but I don?t really know how to write the Code, cause this don?t really work.
Code example:

Dim proc as ManagementClass("Win32_process")
Dim method() as Object = listbox1.items(listbox1.SelectedIndex), nothing)

try

if listbox1.SelectedIndex = -1 then
MessageBox.show ("Please select a Process")

else

proc.InvokeMethod("Terminate", method)

end if

Any Idea?s ???
thanks

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>foqnHOg7Vk2Mc1AVqDQLWQ==</Id>

Nov 20 '05 #2
* Peter Neuburger via .NET 247 <an*******@dotnet247.com> scripsit:
I need some help with the WMI Terminate Method.

I have a Listbox where I get all the Process Information using the WMI Win32_process
class, that works fine.

Now I have a Stop Button that should terminate the process when I select it in the listbox
but I don?t really know how to write the Code, cause this don?t really work.


If youi don't get an answer here, you may want to turn to this group:

<URL:news://news.microsoft.com/microsoft.public.dotnet.framework.wmi>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
Hi,

Add a reference to system.management.dll. This will start notepad list all
the processes and owners and kill notepad when it finds it on the list.

Process.Start("notepad")
Dim moReturn As Management.ManagementObjectCollection
Dim moSearch As Management.ManagementObjectSearcher
Dim mo As Management.ManagementObject

moSearch = New Management.ManagementObjectSearcher("Select * from
Win32_Process")

moReturn = moSearch.Get
For Each mo In moReturn
Dim args(2) As String
mo.InvokeMethod("GetOwner", args)
Dim strOut As String
strOut = String.Format("{0} - Owner {1}",
mo("Caption").ToString, args(0))
Trace.WriteLine(strOut)
If mo("Caption").ToString = "notepad.exe" Then
Dim objTerm(2) As Object
mo.InvokeMethod("Terminate", objTerm)
End If
Next

Ken
-------------------
"Peter Neuburger via .NET 247" <an*******@dotnet247.com> wrote in message
news:OH**************@TK2MSFTNGP10.phx.gbl...
(Type your message here)

--------------------------------
From: Peter Neuburger

Hi Everybody,

I need some help with the WMI Terminate Method.

I have a Listbox where I get all the Process Information using the WMI
Win32_process
class, that works fine.

Now I have a Stop Button that should terminate the process when I select
it in the listbox
but I don?t really know how to write the Code, cause this don?t really
work.

Code example:

Dim proc as ManagementClass("Win32_process")
Dim method() as Object = listbox1.items(listbox1.SelectedIndex), nothing)

try

if listbox1.SelectedIndex = -1 then
MessageBox.show ("Please select a Process")

else

proc.InvokeMethod("Terminate", method)

end if

Any Idea?s ???
thanks

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>foqnHOg7Vk2Mc1AVqDQLWQ==</Id>

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Bob Rock | last post by:
Hello, coming from win32 API I recall an ExitThread() call to gently terminate a thread from inside the same thread .... but now all I can see is an Abort call which seems to me a wrapper on the...
3
by: abovetreeline | last post by:
Hi, How to make javascript terminate a win32_process? vbscript will terminate a named process with the following code: strcomputer = "." Set objwmiservice = GetObject("winmgmts:" _ &...
4
by: Dr. J | last post by:
How to terminate a blocked thread? In my form's "load" I launch a TCP listening thread that stays in an infinite loop waiting for incoming TCP packets. In this form's "closing" I try to...
2
by: David Morris | last post by:
Hi I want to add multiple items (about 20) to a checked list box control at run time, but do not know how to use the AddRange method of the Items collection. Currently, I am using the Add method,...
2
by: Christoph Borger | last post by:
Hello! I have wrote a windows service in vb.net. This service monitors the running processes with WMI and the Win32_Process class. Till last month all seems ok. But since the begin of september...
1
by: tony | last post by:
Hello!! Hello Victor! I use a product called flygrid to create grid tables. In many of my forms I create such grid tables. Some columns in these grid tables is of type drop down list where I...
1
by: lance2001 | last post by:
Hi, After viewing the entire Visual Basic 2005 Express Edition for Beginners video series, I have begun building a database driven application that will make use of listbox1 (multi-select)...
5
by: lukasmazur | last post by:
Hi I have a problem with using listBox1. I have a two forms form1 and form2. In form1 are controls listBox1, textBox1 and button witch creating object of class Form2. In class Form2 I create a...
1
by: Kerem Gümrükcü | last post by:
Hi, i try to create a remote process with Win32_Process.Create, but the remote machine always retruns 9 as result, which say that the path could not be found. Code seems to be fine, except the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.