Command-line switches for InfoPath

This article shows you how to customize the way that Microsoft Office InfoPath starts by adding switches and parameters to the startup command. You can also use these switches and parameters with the startup command in a batch file or at a command prompt.

Note: Command-line switches are also called command-line options or command-line parameters.

For example, you can use these switches and parameter to start InfoPath with a specified form template, start InfoPath with a specified form template that accepts input parameters, or clear the cache of all form templates. If you want to use a switch and any associated parameters on a single occasion, you can type the command in the Run dialog box (Start button) in Microsoft Windows. However, if you want to use the same switch and parameters every time that you open InfoPath, you can create a desktop shortcut to accomplish this.

In this article

Use a switch once by adding it to the Run command

Make a switch available for reuse by creating a shortcut

Available switches and parameters

Use a switch once by adding it to the Run command

To complete this procedure you must first verify the location of the InfoPath.exe file on your computer. If you accepted the default folder locations when you installed InfoPath, the InfoPath.exe file is probably located at C:\Program Files\Microsoft Office\Office 12\. If you do not find the InfoPath.exe file at that location, search for the file and make a note of the fully qualified path.

  1. In Microsoft Windows, click the Start button, and then click Run.

  2. In the Run dialog box, type a double quotation mark, the full path for the InfoPath.exe file (including the file name), and then a double quotation mark.

  3. After the double quotation mark, type a space followed by the switch and any parameters that you want to use. For example, you might type: "C:\Program Files\Microsoft Office\Office12\InfoPath.exe" \\Reports\NewForms\ExpenseReportTemplate.xsn /InputParameters department=10&organization=325.

    Note: Switches and parameters are not case-sensitive. For example, /A is the same as /a. Remember to include one blank space before the switch and one blank space before each parameter. If the parameter contains spaces, start and end the parameter with double quotation marks.

The next time that you start InfoPath, the program will return to its previous default startup settings. To make your customized startup settings available for repeated use, see the next section.

Top of Page

Make a switch available for reuse by creating a shortcut

To make your customized startup settings available for repeated use, you can save them on your desktop as a shortcut. To complete this procedure you must first verify the location of the InfoPath.exe file on your computer. If you accepted the default folder locations when you installed InfoPath, the InfoPath.exe file is probably located at. C:\Program Files\Microsoft Office\Office 12\. If you do not find the InfoPath.exe file at that location, search for the file and make a note of the full path.

  1. Right-click the Windows desktop, point to New, and then click Shortcut on the shortcut menu.

  2. In the Create Shortcut Wizard, in the Type the location of the item box, type a double quotation mark, the full path for the InfoPath.exe file (including the file name), and then a double quotation mark.

  3. After the double quotation mark, type a space followed by the switch and any parameters that you want to use. For example, you might type: "C:\Program Files\Microsoft Office\Office12\InfoPath.exe" \\Reports\NewForms\ExpenseReportTemplate.xsn /InputParameters department=10&organization=325.

    Note: Switches and parameters are not case-sensitive. For example, /A is the same as /a. Remember to include one blank space before the switch and one blank space before each parameter. If the parameter contains spaces, start and end the parameter with double quotation marks.

  4. Click Next.

  5. In the Type a name for this shortcut box, type a name for the shortcut, and then click Finish. The wizard creates the shortcut and places it on the desktop.

You can create a variety of shortcuts, each of which applies different switches and parameters to the program at startup.

Top of Page

Available switches and parameters

The following table lists all of the switches and parameters that are available in InfoPath.

Switch and Parameter

Description

form

Opens the specified form so that you can fill it out. The name of the form can be a file name, a fully qualified path and file name, or a Uniform Resource Name (URN).

Example    To start InfoPath and open the form MyForm.xml, type the following:

"C:\Program Files\Microsoft Office\Office12\InfoPath.exe" "C:\New Forms\MyForm.xml"

form template

Opens a new form, based on the specified form template, so that you can fill it out. The name of the form can be a file name, a fully qualified path and file name, or a URN.

Example    To start InfoPath and open a new form based on the form template ExpenseReportTemplate.xsn, type the following:

"C:\Program Files\Microsoft Office\Office12\InfoPath.exe" ExpenseReportTemplate.xsn

form template /InputParameters param1=value&param2=value&param3=value

Opens a new form, based on the form template published to a shared network location, and passes the parameters to the form. The form template must have managed code or script to process the parameters in the /InputParameters option. The name of the form template can be a file name, a fully qualified path and file name, or a URN.

The parameter list starts after InfoPath.exe with a space, and is then followed by the name of the parameter, an equal sign (=), and the value of the parameter. Each parameter is separated by an ampersand (&). Do not use a space between the question mark and each parameter.

A parameter name without a value is passed as a parameter with a null value, and a value without a corresponding parameter name is ignored.

For more information about processing input parameters, see the InfoPath developers reference.

Example    Imagine that you have a form template, ExpenseReportTemplate.xsn, with a script that can process two input parameters called department and organization. The form template was published to a shared network folder called NewForms on a server called Reports. To start InfoPath and open a new form template with a department parameter that is equal to 10 and an organization parameter that is equal to 325, type the following:

"C:\Program Files\Microsoft Office\Office12\InfoPath.exe" \\Reports\NewForms\ExpenseReportTemplate.xsn /InputParameters?department=10&organization=325

form template /InputParameters?param1=value&param2=value&param3=value

Opens a new form based on the form template that is published to a server running Windows SharePoint Services 3.0 or Microsoft Office SharePoint Server 2007, and then passes the parameters to the form. The form template must have managed code or script to process the parameters in the /InputParameters option. The name of the form template can be a file name, a fully qualified path and file name, or a URN.

The parameter list starts with a question mark (?), followed by the name of the parameter, an equal sign (=), and the value of the parameter. Each parameter is separated by an ampersand (&). Do not use a space between the question mark after the /InputParameter switch and each parameter.

A parameter name without a value is passed as a parameter with a null value, and a value without a corresponding parameter name is ignored.

For more information about writing managed code for input parameters, see the InfoPath developers reference.

Example    Imagine that you have a form template, ExpenseReportTemplate.xsn, with managed code that can process two input parameters called department and organization. The form template was published to a server running Windows SharePoint Services 3.0 with the URL http://fabrikam. To start InfoPath and open a new form template with a department parameter that is equal to 10 and an organization parameter that is equal to 325, type the following:

"C:\Program Files\Microsoft Office\Office12\InfoPath.exe" http://fabrikam/ExpenseReportTemplate.xsn /InputParameters?department=10&organization=325

/new form /defaultsavelocation <URL>

The /new option opens the existing form and the /defaultsavelocation option sets the path for the Save As dialog box to the specified Uniform Resource Locator (URL). The URL will appear in the Save As dialog box the first time that the form is saved.

Example    To start InfoPath, open the form MyForm.xml, and set the path where the user can save the form to C:\MyForms, type the following:

"C:\Program Files\Microsoft Office\Office12\InfoPath.exe" /new MyForm.xml /defaultsavelocation C:\MyForms

form template /defaultsavelocation <URL>

Opens a new form based on the form template and sets the path for the Save As dialog box to the specified URL. The URL will appear in the Save As dialog box the first time that the form is saved.

Example    To start InfoPath, open a new form based on the form template ExpenseReportTemplate.xsn, and then set the path where you want the user to save the form to the Windows SharePoint Services document library http://fabrikam/sites/Reports, type the following:

"C:\Program Files\Microsoft Office\Office12\ExpenseReportTemplate.xsn" /defaultsavelocation http://fabrikam/sites/Reports

/aggregate "form1|form2|form3" "form template"

Merges the forms into a new form that is based on the form template. The forms must be separated by a pipe (|) character, and all of the forms must be enclosed in quotation marks (").

Example    Imagine that you want to merge the forms MyForm1.xml and MyForm2.xml into a new form that is based on the form template ExpenseReportTemplate.xsn. The new form template is stored on your computer in the Forms folder. To start InfoPath and merge the two existing forms, type the following:

"C:\Program Files\Microsoft Office\Office12\InfoPath.exe" /aggregate "MyForm1.xml|MyForm2.xml" C:\Forms\ExpenseReportTemplate.xsn

/design form template

Opens the specified form template in design mode. If no form template is specified, InfoPath starts in design mode without a form template.

Example    To start InfoPath in design mode with the form template ExpenseReportTemplate.xsn, type the following:

"C:\Program Files\Microsoft Office\Office12\InfoPath.exe" /design ExpenseReportTemplate.xsn

/design form template /readonly

Opens the specified form template in design mode. You can make changes to the form template, but you must save the form template to a location other than where you opened the form template.

Tip: Use this option to open and modify an existing form template that has been published. This switch can help prevent you from accidentally overwriting the form template in the publish location by requiring you to save the form template to another location. If you overwrite a published form template by saving the form template at the publish location rather than by using the Publishing Wizard, users may not be able to create a new form or modify existing forms that are based on this form template. After you save the form template to another location and then modify the form template, you can use the Publishing Wizard to publish and overwrite the form template at the publish location.

Example    To start InfoPath in design mode with the form template ExpenseReportTemplate.xsn, and to help ensure that you will not overwrite the form template at the original location, type the following:

"C:\Program Files\Microsoft Office\Office12\InfoPath.exe" /design ExpenseReportTemplate.xsn /readonly

/embedding

Starts InfoPath without displaying the Microsoft Office InfoPath window. Developers use this option when testing custom applications with InfoPath.

Example    To do this, type the following:

C:\Program Files\Microsoft Office\Office12\InfoPath.exe" /embedding

/cache ClearAll

Starts InfoPath and clears the cache in which form templates are stored on the computer. Use this option to remove unused form templates from your users' computers and to increase available disk drive space. You can use this option with an existing form or a new form that is based on the form template.

Example    To start InfoPath, open the form MyForm.xml, and then clear the cache of all form templates, type the following

"C:\Program Files\Microsoft Office\Office12\InfoPath.exe" MyForm.xml /cache ClearAll


Top of Page

Share Facebook Facebook Twitter Twitter Email Email

Was this information helpful?

Great! Any other feedback?

How can we improve it?

Thank you for your feedback!

×