ProcessStartInfo.Verb Property

Gets or sets the verb to use when opening the application or document specified by the FileName property.

Namespace: System.Diagnostics
Assembly: System (in system.dll)

'Declaration
Public Property Verb As String
'Usage
Dim instance As ProcessStartInfo
Dim value As String

value = instance.Verb

instance.Verb = value
/** @property */
public String get_Verb ()

/** @property */
public void set_Verb (String value)

public function get Verb () : String

public function set Verb (value : String)

Property Value

The action to take with the file that the process opens. The default is an empty string ("").

Each file name extension has its own set of verbs, which can be obtained using the Verbs property. For example, the "print" verb will print a document specified using FileName. The default verb can be specified using an empty string ("").

When you use the Verbs property, you must include the file name extension when you set the value of the FileName property. The file name does not need to have an extension if you manually enter a value for the Verb property.

The following example starts a new process using the specified action and file name.

Public Shared Sub StartWithVerb(fileName As String, verb As String, _
                                args As String)

   If Not (fileName Is Nothing) AndAlso fileName.Length > 0 _
      AndAlso Not (verb Is Nothing) AndAlso verb.Length > 0

       If File.Exists(fileName)

           Dim startInfo As ProcessStartInfo
           startInfo = New ProcessStartInfo(fileName)

           startInfo.Verb = verb
           startInfo.Arguments = args

            Dim newProcess As New Process()
            newProcess.StartInfo = startInfo
            
            Try
               newProcess.Start()
               
               Console.WriteLine( _
                   "{0} for file {1} started successfully with verb ""{2}""!", _
                   newProcess.ProcessName, fileName, startInfo.Verb)


            Catch e As System.ComponentModel.Win32Exception
               Console.WriteLine("  Win32Exception caught!")
               Console.WriteLine("  Win32 error = {0}", e.Message)

            Catch e As System.InvalidOperationException
                ' Catch this exception if the process exits quickly, 
                ' and the properties are not accessible.
                Console.WriteLine("File {0} started with verb {1}", _
                    startInfo.FileName, startInfo.Verb.ToString())

            End Try
       
       End If
    End If
End Sub

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0

Community Additions

ADD
Show: