This documentation is archived and is not being maintained.

Process.MainWindowTitle Property

Gets the caption of the main window of the process.

[Visual Basic]
Public ReadOnly Property MainWindowTitle As String
public string MainWindowTitle {get;}
public: __property String* get_MainWindowTitle();
public function get MainWindowTitle() : String;

Property Value

The process's main window title.


A process has a main window associated with it only if the process has a graphical interface. If the associated process does not have a main window (so that MainWindowHandle is zero), MainWindowTitle is an empty string (""). If you have just started a process and want to use its main window title, consider using the WaitForInputIdle method to allow the process to finish starting, ensuring that the main window handle has been created. Otherwise, the system throws an exception.

Windows 98 Platform Note:  This property is not available on this platform if you started the process with ProcessStartInfo.UseShellExecute set to true.


[Visual Basic, C#, C++] The following example starts an instance of Notepad and retrieves the caption of the main window of the process.

[Visual Basic] 
Imports System
Imports System.Diagnostics

Class MainWindowTitleClass
   Public Shared Sub Main()

         ' Create an instance of process component.
         Dim myProcess As New Process()
         ' Create an instance of 'myProcessStartInfo'.
         Dim myProcessStartInfo As New ProcessStartInfo()
         myProcessStartInfo.FileName = "notepad"
         myProcess.StartInfo = myProcessStartInfo
         ' Start process.
         ' Allow the process to finish starting.
         Console.Write("Main window Title : " + myProcess.MainWindowTitle)

      Catch e As Exception
         Console.Write(" Message : " + e.Message)
      End Try
   End Sub 'Main
End Class 'MainWindowTitleClass

using System;
using System.Diagnostics;

class MainWindowTitleClass
   public static void Main()

         // Create an instance of process component.
         Process myProcess = new Process();
         // Create an instance of 'myProcessStartInfo'.
         ProcessStartInfo myProcessStartInfo = new ProcessStartInfo();
         myProcessStartInfo.FileName = "notepad";
         myProcess.StartInfo = myProcessStartInfo;
         // Start process.
         // Allow the process to finish starting.
         Console.Write("Main window Title : " + myProcess.MainWindowTitle);

      catch(Exception e)
         Console.Write(" Message : " + e.Message);

#using <mscorlib.dll>
#using <System.dll>

using namespace System;
using namespace System::Diagnostics;

int main() {
    try {
        // Create an instance of process component.
        Process* myProcess = new Process();
        // Create an instance of 'myProcessStartInfo'.
        ProcessStartInfo* myProcessStartInfo = new ProcessStartInfo();
        myProcessStartInfo->FileName = S"notepad";
        myProcess->StartInfo = myProcessStartInfo;
        // Start process.
        // Allow the process to finish starting.
        Console::Write(S"Main window Title : {0}", myProcess->MainWindowTitle);

    } catch (Exception* e) {
        Console::Write(S" Message : {0}", e->Message);

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

Process Class | Process Members | System.Diagnostics Namespace