See Using the samples for help on compiling, setting up the debugger, and running the sample (either an exe or dll).
Open and compile the sample project in Visual Studio 2005.
Run DesktopAutomationCS.exe or DesktopAutomationVB.exe depending on the language version.
Select ArcMap, ArcScene, or ArcGlobe from the application drop-down list and click Start to start a new application session. Note the change in the state of the Start (becomes unavailable) and the Exit (becomes available) buttons.
Type the path of a valid shapefile in the text box. Click Add Layer to add it to the new application session.
Click Exit to shut down the application session. Note the change in the state of the Start (becomes available) and the Exit (becomes unavailable) buttons.
Steps 7–9 demonstrate how to handle modal dialog boxes when exiting the application.
Start the application as in Step 3.
Open a modal dialog box of the application; for example, click the Add Data button.
With the Add Data dialog box displayed, click Exit to shut down the application session.
Steps 11–12 show how to handle the manual application shutdown in an automation session.
Start the application as in Step 3.
Close the newly started application manually by choosing File, then Exit or click the Close (X) button on the title bar. Note the change in the state of the Start (becomes available) and the Exit (becomes unavailable) buttons.