Export (0) Print
Expand All
1 out of 1 rated this helpful - Rate this topic

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
<TypeConverterAttribute("System.Diagnostics.Design.VerbConverter, System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")> _
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)

Not applicable.

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 by using the Verbs property. For example, the "print" verb will print a document specified by using FileName. The default verb can be specified by using an empty string (""). Examples of verbs are "Edit", "Open", "OpenAsReadOnly", "Print", and "Printto". You should use only verbs that appear in the set of verbs returned by the Verbs property.

When you use the Verb 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 code example starts a new process by using the specified verb and file name. This code example is part of a larger example provided for the Verbs property.

    startInfo = New ProcessStartInfo(fileName)

    If File.Exists(fileName) Then
        i = 0
        Dim verb As String
        For Each verb In startInfo.Verbs
            ' Display the possible verbs.
            Console.WriteLine("  {0}. {1}", i.ToString(), verb)
            i += 1
        Next verb
    End If
Else
    ' Return if no file is selected.
    Return
End If

Console.WriteLine("Select the index of the verb.")
Dim index As String = Console.ReadLine()
If Convert.ToInt32(index) < i Then
    verbToUse = startInfo.Verbs(Convert.ToInt32(index))
Else
    Return
End If

startInfo.Verb = verbToUse
If verbToUse.ToLower().IndexOf("printto") >= 0 Then
    ' printto implies a specific printer.  Ask for the network address.
    ' The address must be in the form \\server\printer.
    Console.WriteLine("Enter the network address of the target printer:")
    arguments = Console.ReadLine()
    startInfo.Arguments = arguments
End If

Windows 98, Windows Server 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 Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.