473,608 Members | 2,592 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Process.Kill:Ho w to kill an attached debugger?

Hi All,

I am writing a tool, which should monitor some exe-processes, which are not
very solid. Th main function is to re-start them, if they hung, but this is
complicated. I can detect things like no longer generating IO or such
properties and I use WMI to do that. I am also looking for attached
subprocesses, which are one of the system debuggers.

I wrote a test-program, which creates a divide by zero error after some
seconds. I can detect - with the help of wmi - that my watched process get's
a subprocess attached, which is, for example, "vs7jit.exe " and I know the
handle.

Then I do:

Process p = Process.GetProc essById(pid/handle);
p.Kill();

I can verify by logging and with the help of "TLIST.EXE" [from the resource
kit], that I got the right PID and that "Kill()" works, but not as expected:
After Kill(), the debugger is not removed [the GUI stays visible] and is
appearing with another PID as a subprocess of "svchost.ex e". Also using
"p.CloseMainWin dow()" is not usable, because it returns false [the docs
explain one of the reasons, which fit in my case:The process has "a modal
dialog is being shown"].

How can I kill the debugger, so that my program dies [this is handled and
the process can be restarted]. Configuring the system to never display a
debugger is not an option for other reasons. The
Management.Win3 2_Process.Termi nate method could be another option, so I post
this to the WMI group also. My proggi is written in C#.

And help would be great!!!!

Best regards,
Manfred Braun

(Private)
Mannheim
Germany

mailto:_m****** *******@manfbra un.de
(Remove the anti-spam-underscore to mail me!)
Nov 17 '05 #1
1 3139
Consider using the AppActivate method (non-WMI) combined with SendKeys to
issue the Quit command on the debugger window - it will take the attached
process down with it.

Dim l_wsh, l_bLnAppRunning , l_StrAppTitle, l_intTimeout
const c_intTimeout = 240000 ' time this script out in 4 minutes
const c_intSleeptime = 200 ' sleep for 1/4th second at a time

Set l_wsh = CreateObject("W script.Shell")
l_bLnAppRunning = false

l_intTimeout = 0

l_StrAppTitle = "Your Debugger Window Title"

' do this until the app activates successfully or timeout
Do While l_bLnAppRunning = False

' try to activate the application with specified title
l_bLnAppRunning = l_wsh.AppActiva te(l_StrApptitl e)

' closes the application
If l_bLnAppRunning Then
' send an ALT and F4 key stroke - your key stroke may vary...
l_wsh.SendKeys "%{F4}"
End If

' sleep
WScript.Sleep c_intSleeptime

' prevents a hang
if l_intTimeout >= c_intTimeout then
l_bLnAppRunning = true ' just to avoid any possible hangs
exit do
else
l_intTimeout = l_intTimeout + c_intSleeptime
end if

Loop

Wscript.Quit 0

--
Scott McNairy
Microsoft MVP - Windows Server Management Infrastructure
"Manfred Braun" <aa@bb.cc> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
Hi All,

I am writing a tool, which should monitor some exe-processes, which are
not
very solid. Th main function is to re-start them, if they hung, but this
is
complicated. I can detect things like no longer generating IO or such
properties and I use WMI to do that. I am also looking for attached
subprocesses, which are one of the system debuggers.

I wrote a test-program, which creates a divide by zero error after some
seconds. I can detect - with the help of wmi - that my watched process
get's
a subprocess attached, which is, for example, "vs7jit.exe " and I know the
handle.

Then I do:

Process p = Process.GetProc essById(pid/handle);
p.Kill();

I can verify by logging and with the help of "TLIST.EXE" [from the
resource
kit], that I got the right PID and that "Kill()" works, but not as
expected:
After Kill(), the debugger is not removed [the GUI stays visible] and is
appearing with another PID as a subprocess of "svchost.ex e". Also using
"p.CloseMainWin dow()" is not usable, because it returns false [the docs
explain one of the reasons, which fit in my case:The process has "a modal
dialog is being shown"].

How can I kill the debugger, so that my program dies [this is handled and
the process can be restarted]. Configuring the system to never display a
debugger is not an option for other reasons. The
Management.Win3 2_Process.Termi nate method could be another option, so I
post
this to the WMI group also. My proggi is written in C#.

And help would be great!!!!

Best regards,
Manfred Braun

(Private)
Mannheim
Germany

mailto:_m****** *******@manfbra un.de
(Remove the anti-spam-underscore to mail me!)

Nov 17 '05 #2

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

Similar topics

6
25852
by: Matthew Wieder | last post by:
What permissions must a user have to be able to succesffuly execute a Process.Kill? I can run it with Admin privleges but not with regular user priveleges - I get an "Access is Denied." The client should be able to run our software was a regular user, so what additional permission must I grant that user for this to work? thanks!
0
1737
by: marccruz | last post by:
Given an instance of System.Diagnostics.Process, how can I get the parent process o Given an instance of System.Diagnostics.Process, how can I get the child processes For example, I start a process which executes a script that starts a java program System.Diagnostics.Process proc = System.Diagnostics.Process() proc.StartInfo.FileName = "test.bat"
4
4689
by: Peter Steele | last post by:
I want to trap any attempts to kill my C# application and so that I can execute shutdown code and let the app die gracefully. How can this be done?
7
10155
by: yaron | last post by:
Hi, I am looking for doing this : void OnKillProcess() { do Cleanup; } i don't want to use ~MyClass() (or Finalize), because i wan't that
0
1529
by: Darren Mart via DotNetMonster.com | last post by:
The question: are any user groups besides Administrators permitted to kill processes? Need more info? Happy to oblige: - I'm writing a business object that will run as a service under a specific username (won't run as System). - the object creates an instance of Word and automates a Mail Merge. (Yes, I know this is not recommended -- that's another thread for another day...)
2
2796
by: Guy_B | last post by:
Hi I am using the filesystem watcher to pick up files as they are dropped into a folder - the files are output file from another system and I have no control over that. When 'watcher raises the event that a new file has appeared then sometimes I can read the file even tho it is still being written but it is incomplete. Other time a file access error occurs. I need to write a test that will see if any other process is still using the...
0
1190
by: Tom Plunket | last post by:
Google indicates that wx.Process.Kill hadn't been implemented some time ago in wxPython for Win32. Is that still the case? It's kind of a drag since several sources (including wxPython wiki) strongly advise (by my reading and intended use) using wxProcess over the built-in stuff, but it's not entirely useful if I can't kill long-running processes from an external driver. To tie into my previous question about mocking in Python, I've...
0
834
by: KUTTAN | last post by:
How can i determine whether a file is being used by a any process ? senario I am creating some pdf files on a server and mails it to some people as attachment. After it i have done the coding to delete all files in the perticular directory Since the files are being appended to mail i am getting error like "the file is being used by other process......" So how can i deter mine that a file is used by any process
0
883
by: News.Individual.NET | last post by:
Hi everyone, It is easy enough to get all sort of info on a running process but is it possible - as it is with WMI - to get the whole command line, that is the executable and whatever file it may have been passed as an argument? For Each proc As Process In pList myProcessModule = proc.MainModule
0
8057
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
7998
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
8470
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...
1
6010
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
5475
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();...
0
3959
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4022
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1580
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1327
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.