![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
|
| | LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | How to terminate a Win32 process without using "winmgmts:" Hello, I use the following script to terminate the process listed in it. As the server gets loaded killing the process (terminate()) takes longer as the load increases. The WMI service takes longer find and kill the process. Other than calling WMI, is there another way to kill the process via script that doesn't take a long time? strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colProcessList = objWMIService.ExecQuery _ ("Select * from Win32_Process Where Name = 'pcsws.exe'") For Each objProcess in colProcessList colProperties = objProcess.GetOwner(strNameOfUser) If strusername = strnameofuser Then objProcess.Terminate() Else End If Next -- Smoreno - ADOT |
My System Specs![]() |
| | #2 (permalink) | ||||||||||||
| Guest | Re: How to terminate a Win32 process without using "winmgmts:" "Smoreno" <Smoreno@xxxxxx> wrote in message news:BC3F0888-3984-455B-8752-69DEEF321B11@xxxxxx
http://technet.microsoft.com/en-us/l.../bb491009.aspx I don't know if it is going to be faster or not, but it does allow you to filter by username. | ||||||||||||
My System Specs![]() | |||||||||||||
| | #3 (permalink) | ||||||||||||||||||||||||
| Guest | Re: How to terminate a Win32 process without using "winmgmts:" Hello, how do you determine the process id for the app to kill? This is a Citrix environment so I need to make sure that the only the process ID for a specific user is killed. Don't we have to use WMI to determine the process ID for that? -- Smoreno - ADOT "James Whitlow" wrote:
| ||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||
| | #4 (permalink) | ||||||||||||||||||||||||||||||||||||
| Guest | Re: How to terminate a Win32 process without using "winmgmts:" >> "Smoreno" <Smoreno@xxxxxx> wrote in message
'taskkill.exe' allows you to specify a username, so you should be able to isolate it's task killing to a specific user. I have not used 'taskkill.exe' before, I was just offering it up as an alternative to WMI. Can you offer the group additional details on what you are trying to accomplish? We might be able to offer you other options if we better understand what you are trying to accomplish. | ||||||||||||||||||||||||||||||||||||
My System Specs![]() | |||||||||||||||||||||||||||||||||||||
| | #5 (permalink) | ||||||||||||
| Guest | Re: How to terminate a Win32 process without using "winmgmts:" Smoreno wrote:
In addition to wmi and the previously mentioned TaskKill, I suggest taking a look at sysInternals "Process Explorer": http://technet.microsoft.com/en-us/s.../bb896653.aspx The sysInternals group was previously run by Mark Russinovich, but has since been taken over by microsoft (as you can see by the url). The Process Explorer utility will tell you everything you ever wanted to know about your running processes, and more to the point will allow you to kill a process (either from the main menu, or a context menu). However, I can't say whether it will be any faster than wmi, except that M.R. is one clever guy and if there is a faster way -- he knows it. The Process Explorer utility is not scriptable, other than via appactivate and sendkeys. However I would strongly advise against sending keys (ever!), and just using the gui provided. If you happen to be courageous enough, or foolhardy enough to call api's from script, then that is probably the "fastest way" to kill a process. There are plenty of code samples available to show how to do it. In short, you "walk-the-process-list" (there are different ways to do this, depending on the system you are using). You walk-the-process-list to get the process ID of the process you are looking to terminate. Then to terminate the process you use OpenProcess to open the process for termination, then you use TerminateProcess api. WMI is nothing more than a scriptable interface to this sort of code. Any delays you are seeing may be due to the fact that it is not so simple to terminate a process. There is a lot of "checking" to do (looking for child threads, child processes, de-allocating system resources, freeing dll's, etc). There is a "laundry list" to things that must be done to properly terminate a process, and that may be taking time. cheers, jw ____________________________________________________________ You got questions? WE GOT ANSWERS!!! ..(but, no guarantee the answers will be applicable to the questions) | ||||||||||||
My System Specs![]() | |||||||||||||
|
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| "This application has requested the Runtime to terminate it in an unusual way." | SapperPest19 | Vista performance & maintenance | 7 | 04-25-2009 11:19 AM |
| How to terminate a "For Each" statement | indytoatl | VB Script | 2 | 09-24-2008 08:50 AM |
| "this application has requested the runtime to terminate in an unusual way" | truebrit | Software | 2 | 08-07-2008 01:06 PM |
| "*.pps is not a valid Win32 application" error message | RaeWeniger | Vista mail | 7 | 03-01-2008 09:44 AM |
| "*.pps is not a valid Win32 application" error message in Windows | RaeWeniger | Vista installation & setup | 2 | 02-19-2008 05:43 PM |