Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Identify and Kill Child Process

Status
Not open for further replies.

Fezbro

Technical User
Jul 9, 2002
17
AU
I have a piece of code that starts a program and runs several parameters. Based on different occurences through the day it can start multiple instances of the same program. At certain points in the programs execution it starts another process. When I start the main program I attach it to a variable so I know what the process ID is so I can kill it.

I can't get hold of the correct process ID of the child process that was launched by the parent I'm trying to kill. I want to kill both the patent and ONLY it's associated child process.

Can anyone help?
 
Use the Process.Kill statement. Here is a brief example.

Code:
Dim MyProcess As New System.Diagnostics.Process
        MyProcess.StartInfo.CreateNoWindow = True
        MyProcess.StartInfo.UseShellExecute = True
        MyProcess.StartInfo.WorkingDirectory = "C:\Program Files\Microsoft Visual Studio\Vfp98\"
        MyProcess.StartInfo.FileName = "VFP6.EXE"
        MyProcess.StartInfo.Arguments = "F:\Projects\AdministratorProjects\OrderEntry-New\DB\Test.PRG"
        MyProcess.Start()
'''I only put the kill process here for illustration
        MyProcess.Kill()

I hoope this helps.


Ron Repp

If gray hair is a sign of wisdom, then I'm a genius.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top