The runCommand provider provides a convenient way to run an executable (.exe), batch (.bat), or command (.cmd) file remotely as part of a Web Deploy operation. The provider accepts an argument that contains the path to a batch file, command file, or executable file. If you specify a batch file or a command file, the file will be streamed to the destination computer and run as a local command on the destination computer. The executable files that are referred to in the command or batch file will not be copied; they must be already present on the destination computer. If the specified command contains spaces, the entire command must be enclosed in quotation marks.

If you use runCommand entries in a manifest file, and the argument for runCommand contains special characters such as the conditional combination symbol "&&", you must convert the special characters into character entities (for example, "&amp;&amp;") so that the XML of the manifest file will be valid. For example, the following command calls a manifest file that uses the runCommand provider to stop the Web Deployment Agent Service and then start it if the stop command is successful.

<BOOL> must be true or false. True if the argument to the runCommand provider is treated as a path to a separate executable (.exe) file; false if it is the path to a batch (.bat) file or command (.cmd) file. The default is false. By default, the runCommand provider treats its specified argument as batch or command file and calls the Windows shell command (cmd.exe /c <batchfilename>) on the destination. If you want to run a destination executable file directly, set the dontusecommandexe provider setting to true. This will cause the executable file that you specify to be called directly ("filename.exe" instead of "cmd.exe /c filename.exe").

Specifies the number of times the runCommand provider will retry after a failure. <number> specifies the number of retries. The valid integer range is from 0 through 2147483647. The default number of retries is 5. By default, there is a delay of one second between each retry.

Specifies, in milliseconds, the interval between runCommand provider retry attempts. The valid integer range is from 0 through 2147483647. The default is 1000 (one second).

Note

The waitAttempts and waitInterval provider settings are specific to the runCommand provider and can be set separately from the -retryAttempts and -retryInterval operation settings, although their default values are the same. The -retryAttempts and -retryInterval operation settings apply to an entire Web Deploy command. Since -retryAttempts and -retryInterval are not provider-specific, they can be used by any provider to handle retry logic. They are especially useful when files may be in use, such as with the contentPath, dirPath, and filePath providers. For more information about -retryAttempts and –retryInterval, see Web Deploy Operation Settings.

To include commands that run before and after a Web Deploy operation, you can use the runCommand provider with the -presync and -postSync operation settings. This lets you, for example, stop a service, synchronize two Web servers, and start the service all in one command. The following example stops the World Wide Web Publishing Service (W3SVC) on remote computer ServerA, synchronizes the local IIS 6.0 server to ServerA, then starts the W3SVC on ServerA after the synchronization completes.

The runCommand provider may not execute when WMSvc is running through an impersonated account. There are two possible solutions for this issue: one is to add necessary privileges to WMSvc; the other is to add the "Replace a process level token" privilege to the user account that will execute commands for the provider.

Caution

Allowing users to use runCommand through the WMSvc is a security risk and should be avoided if possible.

Avoid adding privileges to the WMSvc if you can. Adding privileges to WMSvc will give everyone who has rights to connect to the server the right to execute commands on the server.

The WMSvc uses a Local Service SID account that has fewer privileges than the Local Service account itself. To add the additional privileges to WMSvc, type the following command at an administrative command prompt.