|
|
How Do I...Start and stop a process?You can use the Process component to accomplish most process management tasks quickly and easily. You can use this component to work with processes on either local or remote computers. On a local computer, you can, for example, start and stop a process.This sample illustrates how to start and stop an executable. It is a small console application that can be run from a command prompt. The application takes one command line argument. The argument is a full path to the executable that you are starting. Note: This sample will only work on processes which have a window, and wait for input. Using this sample on a process which does not meet these criteria will cause an exception to be thrown. For example, if you want to start and then stop Notepad, run the sample with the following command line argument: > ProcessDemo.exe c:\winnt\notepad.exe You will see Notepad started and then closed after approximately 1 second. In its simplest form, starting a process involves:
A call to WaitForInputIdle will make sure the application actually starts and is ready for use. Example
|