Activate another running program in C#

This is actually quite simple. First add a reference to the Microsoft.VisualBasic library. Then call Microsoft.VisualBasic.Interaction.AppActivate passing it the title of the program you want to activate as in the following code.

// Activate the program.
private void btnActivate_Click(object sender, EventArgs e)
{
    Microsoft.VisualBasic.Interaction.AppActivate(txtProgram.Text);
}

Note that the other program must be running or the program throws a "process not found" exception. To start a program that isn't running, see the example Open a file with the system's default application in C#.

   

 

What did you think of this article?




Trackbacks
  • No trackbacks exist for this post.
Comments
  • No comments exist for this post.
Leave a comment

Submitted comments are subject to moderation before being displayed.

 Name

 Email (will not be published)

 Website

Your comment is 0 characters limited to 3000 characters.