Calling External Applications from .NET Applications

Last Updated: Nov 06, 2025
6 min read
Legacy Archive
Legacy Guidance: This article preserves historical web development content. For modern .NET 8+ best practices, visit our Tutorials section.

Calling external applications from your .NET application is something you'll do frequently when developing products. During product installation, you might need to redirect users to web pages on your website where they can get information about your product. This web page might be a user manual in HTML format. Sometimes you need to open a readme file in text format, usually opened using Notepad. Many requirements exist that need you to call external applications from your .NET application.

We'll look at some simple examples of how to call and execute external applications. For this, we'll create a console application with straightforward code that demonstrates the Process class capabilities.

Basic Process.Start Example

The simplest way to launch an external application is using the Process.Start method. Here's how to open Microsoft Word from your .NET console application:

Launch Word Application
Module Module1
    Sub Main()
        System.Diagnostics.Process.Start("winword.exe")
    End Sub
End Module

This code opens the Word application and then your application terminates. If you want to open an existing Word document, you can pass the filename as a second argument to the Start method:

Open Specific Document
Module Module1
    Sub Main()
        System.Diagnostics.Process.Start("winword.exe", "first.doc")
    End Sub
End Module

For the document to open properly, you should have the file in the folder that contains your application's executable file. Or you can specify the full path to avoid problems locating the file:

Full Path Specification
System.Diagnostics.Process.Start("winword.exe", "c:\first.doc")

Making Your Application Wait

Your application terminates after opening the document. If you want to make your application wait while you work in the document, you can use the WaitForExit method of the process. A small change in your code makes your application wait:

Wait with Timeout
Dim p As New System.Diagnostics.Process()
p.Start("winword.exe", "c:\first.doc")
p.WaitForExit(10000)

This code makes your application wait for 10 seconds before it terminates. If you don't pass any arguments to WaitForExit, it will make your application wait indefinitely until you close the external application.

Using ProcessStartInfo

You can set many other process information properties for the process that opens the external application. For the MS Word application, you can also set other process information as shown below:

Advanced Process Configuration
Module Module1
    Sub Main()
        Dim pi As New System.Diagnostics.ProcessStartInfo()
        pi.FileName = "winword.exe"
        pi.Arguments = "c:\first.doc"
        pi.WorkingDirectory = "c:\"
        pi.WindowStyle = ProcessWindowStyle.Maximized
        
        Dim p As New System.Diagnostics.Process()
        p.StartInfo = pi
        p.Start()
    End Sub
End Module

You can set process start information properties such as Arguments, WorkingDirectory, and WindowStyle. The Arguments property takes the filename to be opened, and the FileName property takes the application name. You can set the working directory using WorkingDirectory. The window style can be set using the WindowStyle property.

Available Window Styles

The ProcessWindowStyle enumeration offers several options for controlling how the external application window appears:

Window Style Options
// Different window styles available
pi.WindowStyle = ProcessWindowStyle.Normal;     // Default size
pi.WindowStyle = ProcessWindowStyle.Minimized;  // Minimized
pi.WindowStyle = ProcessWindowStyle.Maximized;  // Maximized
pi.WindowStyle = ProcessWindowStyle.Hidden;     // Hidden window

Opening URLs in Default Browser

Sometimes you need to redirect users to a web page on the internet. To achieve this, you can pass the URL to the Start method of the process:

Launch URL
System.Diagnostics.Process.Start("http://www.yoursite.com")

This code opens the default browser in your system to open the website given in the URL passed to the Start method. The system automatically determines which browser to use based on the user's default settings.

C# Examples

The same functionality works in C# with similar syntax. Here are equivalent examples:

C# Process Examples
// Simple launch
Process.Start("notepad.exe");

// Open specific file
Process.Start("notepad.exe", "readme.txt");

// Advanced configuration
ProcessStartInfo startInfo = new ProcessStartInfo
{
    FileName = "notepad.exe",
    Arguments = "readme.txt",
    WorkingDirectory = @"C:\",
    WindowStyle = ProcessWindowStyle.Maximized
};

Process process = new Process { StartInfo = startInfo };
process.Start();
process.WaitForExit();

Common Use Cases

Here are some practical scenarios where calling external applications is useful. Opening PDF files with the default PDF reader, launching help documentation, opening email clients with pre-filled information, or executing command-line utilities. You can also use this technique to open file explorer windows, start system utilities, or launch any installed application.

Thus you find it's easy to call external applications from your .NET application. The Process class provides flexibility and control over how external programs are launched and managed.

Quick FAQ

How do I make my application wait for the external process to complete?

Use the WaitForExit method on the Process object. Call it without parameters to wait indefinitely, or pass a timeout in milliseconds. For example, WaitForExit(10000) waits up to 10 seconds before continuing.

Can I control how the external application window appears?

Yes, use ProcessStartInfo.WindowStyle property. Set it to Normal, Hidden, Minimized, or Maximized. This controls whether the application window appears and how it displays when launched.

How do I open a URL in the default browser from my .NET application?

Simply call Process.Start with the URL as a string parameter. The system automatically opens the default browser with that URL. You don't need to specify the browser executable.

Back to Articles