473,785 Members | 2,291 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Select edIndex), nothing)

try

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

else

proc.InvokeMeth od("Terminate" , method)

end if

Any Idea?s ???
thanks

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

<Id>foqnHOg7Vk2 Mc1AVqDQLWQ==</Id>
Nov 20 '05 #1
3 5923
Alternately, you could use the System.Diagnost ics.Process class, and call
either CloseMainWindow s 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*******@dotn et247.com> wrote in message
news:OH******** ******@TK2MSFTN GP10.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.Select edIndex), nothing)

try

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

else

proc.InvokeMeth od("Terminate" , method)

end if

Any Idea?s ???
thanks

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

<Id>foqnHOg7Vk2 Mc1AVqDQLWQ==</Id>

Nov 20 '05 #2
* Peter Neuburger via .NET 247 <an*******@dotn et247.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.publi c.dotnet.framew ork.wmi>

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

Add a reference to system.manageme nt.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.Mana gementObjectCol lection
Dim moSearch As Management.Mana gementObjectSea rcher
Dim mo As Management.Mana gementObject

moSearch = New Management.Mana gementObjectSea rcher("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").T oString, args(0))
Trace.WriteLine (strOut)
If mo("Caption").T oString = "notepad.ex e" Then
Dim objTerm(2) As Object
mo.InvokeMethod ("Terminate" , objTerm)
End If
Next

Ken
-------------------
"Peter Neuburger via .NET 247" <an*******@dotn et247.com> wrote in message
news:OH******** ******@TK2MSFTN GP10.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.Select edIndex), nothing)

try

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

else

proc.InvokeMeth od("Terminate" , method)

end if

Any Idea?s ???
thanks

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

<Id>foqnHOg7Vk2 Mc1AVqDQLWQ==</Id>

Nov 20 '05 #4

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

Similar topics

11
2216
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 TerminateThread() Win32 API which is a brutal way to end a thread. Is there any other more gentle way to close a thread??? Bob Rock
3
11548
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:" _ & "{impersonationlevel=impersonate}!\\"&strcomputer & "\root\cimv2") Set colprocesslist = objwmiservice.execquery _ ("SELECT * FROM Win32_Process WHERE Name = 'winword.exe'")
4
4940
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 terminate this thread by calling the "Abort" funcion. But the thread does not terminate and after the form is closed this thread keeps running at blocked state. Basically the application keeps running because this thread does not terminate while...
2
6988
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, which works fine, but since I'm dealing with 20 items, this means I have 20 lines of code because the Add method is used once for every item Could somebody please clarify the syntax of the AddRange method? I know you're supposed to use braces "{...
2
7084
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 the service can't retrieve the commandline property of the processes. I think this is an result of .NET Framework 1.1 Service Pack 1 or XP SP2. Did somebody recognice the same effect? Did anybody knows how i can retrieve the commandline property...
1
2347
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 can select a value from the list. Below I have some code which exist in a file named StringClass.cs
1
2084
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) determining what shows up in listbox2 (multi_select), which determines listbox3, etc.... Each each listbox is populated from a different table in the same database. The databinding examples given in the video seem to leave no way for a
5
2531
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 pointer to object of class Form1. I don't known how to use method add(), where can I find it. From Form1 I can add value like this this->listBox1- I cant find it. I have textBox1 on Form1 and I can change text in this control like this ...
1
9747
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 compiler warning (unreachable code, etc) Here is some code: private static Dictionary<string, string>
0
9643
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10147
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8968
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4045
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.