Skip to content

Commands

TechieGuy12 edited this page Jul 12, 2024 · 12 revisions

Commands allows a specified command to execute when a file or folder in a watch path is changed. The commands are specified within the <commands> element that is a child of the <watch> element.

A watch can contain execute multiple commands for a change. Each command is specified within a <command> element within the <commands> element.

Warning: Be careful when running commands. The commands will run under the context of the user that is running File Watcher. If the System or administrator user is running File Watcher, than any commands will run under the System or administrator context.

Structure

<watches>
    <watch>
        <commands>
            <variables></variables>        
            <command>
                <triggers></triggers>
                <variables></variables>                                      
                <path></path>                 
                <arguments></arguments>
                <waitbefore></waitbefore>
            </command>
        </commands>
    </watch>
</watches>

Commands Elements

A <commands> element can contain the following child elements:

Element Description
variables (Optional) (Version 2.x or higher.) The variables for all child steps. For more information, see Variables.
command A command to run.

Command Elements

The following elements are used to specify the command to execute:

Element Description
triggers The triggers for the notification. For more information, see Triggers.
path The full path of the file to execute. Can include Placeholders.
arguments (Optional) Arguments to pass into the command. Can include Placeholders.
waitbefore (Optional) Number of milliseconds to wait before running the command.
variables (Optional) (Version 2.x or higher.) The variables for all child steps. For more information, see Variables.

Triggers

Information about the valid triggers, can be found on the Triggers page.

Path

The full path to the file to execute is specified using the <path> element. The path value specified can use Placeholders to provide dynamic path.

Arguments

Arguments to pass into the execute file are specified using the <arguments> element. This is a string value of all the arguments, so they are not separated by separate child elements within this element. The arguments can use Placeholders to provide dynamic paths for arguments that need such information.

Examples

Call an executable C:\Tools\fv\fv.exe with the arguments -f [exactpath] when a file is created in C:\Temp. If the file created is C:\Temp\test.doc, then the command that is run is C:\Tools\fv\fv.exe -f "C:\Temp\test.doc"

<watches>
    <watch>
        <path>C:\Temp</path>
        <commands>       
            <command>
                <triggers>
                    <trigger>Create</trigger>
                </triggers>                                     
                <path>C:\Tools\fv\fv.exe</path>                 
                <arguments>-f "[exactpath]"</arguments>
            </command>
        </commands>                   
    </watch>    
</watches>
Clone this wiki locally