# Desktop Fileset Timed Events

## Description

Filesets can activate at a specific date and time. For daily maintenance windows, such as installing software only after hours, use a Policy Blocker Script with Custom Fields to decide when the Fileset may continue.

[![image.png](https://kb.filewave.com/uploads/images/gallery/2024-07/scaled-1680-/bUD8dOsEWuj4trrN-image.png)](https://kb.filewave.com/uploads/images/gallery/2024-07/bUD8dOsEWuj4trrN-image.png)

[Policy Blocker Scripts](https://kb.filewave.com/books/filesets-payloads/page/filewave-fileset-types#bkmrk-policy) normally pause client management until the script returns exit status 0. Because this script type runs every 5 minutes on clients, it can also be used as a time-window gate for a Fileset.

Custom Fields make the active and inactive times adjustable per device or group without editing the script each time.

## Ingredients

- One (or more) Custom Fields; 3 provided - [Active Time Custom Fields.customfields](https://kb.filewave.com/attachments/376)
- Policy Blocker Scripts

<table id="bkmrk-macos-windows-policy" style="border-collapse:collapse;width:100%;"><colgroup><col style="width:50%;"></col><col style="width:50%;"></col></colgroup><tbody><tr><td>macOS</td><td>Windows</td></tr><tr><td>[Policy - Timed Event macOS.fileset.zip](https://kb.filewave.com/attachments/377)</td><td>[Policy - Timed Event Windows.fileset.zip](https://kb.filewave.com/attachments/378)</td></tr></tbody></table>

## Directions

- Download and import the provided Custom Fields
- Download and import the appropriate Fileset(s) (macOS and/or Windows)

Set the Custom Field values for the inactive and active times you need. Time values use hours, minutes, and seconds without leading zeros. Examples:

<table id="bkmrk-desired-time-%28hh%3Amm%29" style="border-collapse:collapse;width:100%;height:116px;"><colgroup><col style="width:50%;"></col><col style="width:50%;"></col></colgroup><tbody><tr style="height:29px;"><td style="height:29px;">Desired Time (HH:MM)</td><td style="height:29px;">Custom Field Value (HHMMSS not including leading zeros)</td></tr><tr style="height:29px;"><td style="height:29px;">09:30</td><td style="height:29px;">93000</td></tr><tr style="height:29px;"><td style="height:29px;">12:55</td><td style="height:29px;">125500</td></tr><tr style="height:29px;"><td style="height:29px;">18:00</td><td style="height:29px;">180000</td></tr></tbody></table>

<p class="callout warning">If you change a Custom Field value for a device that is already running the policy, the client may need two later Model Updates for an immediate-looking result. The blocker script runs before the device reads the new Custom Field value during the first update. The next Model Update, or a later inventory update, lets the blocker script evaluate the new value.</p>

### Time Order

Times can be either way around.<span class="Apple-converted-space"> </span>

#### Examples:

Consider working hours to begin at 08:30 and end at 18:00

##### Example 1

An item should only be considered outside of standard working hours.

- Disable Active Time: 83000
- Enable Active Time: 180000

[![image.png](https://kb.filewave.com/uploads/images/gallery/2024-07/scaled-1680-/VDw6zf9ZY5N8bkR3-image.png)](https://kb.filewave.com/uploads/images/gallery/2024-07/VDw6zf9ZY5N8bkR3-image.png)

##### Example 2

Alternatively, an item should be considered during working hours:

- Enable Active Time: 83000
- Disable Active Time: 180000

[![image.png](https://kb.filewave.com/uploads/images/gallery/2024-07/scaled-1680-/BAhhZ995ZBuff2UY-image.png)](https://kb.filewave.com/uploads/images/gallery/2024-07/BAhhZ995ZBuff2UY-image.png)

Imported Custom Fields are disabled for all devices by default. Once tested, consider using the option to assign to all devices for each Custom Field imported. The file provided contains all 3 Custom Fields.

[![image.png](https://kb.filewave.com/uploads/images/gallery/2024-07/scaled-1680-/hJEjRvmBZiHr7czo-image.png)](https://kb.filewave.com/uploads/images/gallery/2024-07/hJEjRvmBZiHr7czo-image.png)

### Smart Groups

A third Custom Field stores a true/false value. A Smart Group can use that value to decide whether a Fileset should be associated at the current time.

<p class="callout info">This Custom Field uses custom\_bool\_01. If that value is already in use, choose another Custom Bool number in the script environment variables.</p>

The script uses the following method to set these values.

[https://kb.filewave.com/books/custom-fields/page/add-filewave-custom-inventory-fields-remotely-using-a-fileset](https://kb.filewave.com/books/custom-fields/page/add-filewave-custom-inventory-fields-remotely-using-a-fileset)

#### Example

An update to Firefox needs to occur after 17:00 or before 09:30

- Disable Active Time = 93000
- Enable Active Time = 170000

Between these times, the 3rd Custom Field ‘Active Time’ should be False/0.<span class="Apple-converted-space"> </span>Outside of these times, the ‘Active Time’ Custom Field should be True/1. <span class="Apple-converted-space"> </span>

[![image.png](https://kb.filewave.com/uploads/images/gallery/2024-07/scaled-1680-/RSitf8u0jR2Hx88v-image.png)](https://kb.filewave.com/uploads/images/gallery/2024-07/RSitf8u0jR2Hx88v-image.png)

Smart Group can be based upon the following:

- Is Active Time True/1
- Is the version of Firefox matching that within the Fileset

<p class="callout warning">Do not base the Smart Group only on the active time unless that is intentional. Devices will enter and leave that Smart Group every day, and associated Filesets can trigger each time the device enters the group.</p>

## Deeper Dive

The Policy Blocker script has 2 considerations initially:

- The hours between which the timed event should occur
- The current time

This means there is a time beyond which the desired action may occur and a time beyond which the action should not occur and this needs to be compared with the current time.

The enable/disable active times are provided by way of Executable Environments.<span class="Apple-converted-space"> </span>Taking this a step further, these times are defined using Administrator Custom Fields.<span class="Apple-converted-space"> </span>This way the times can more easily be altered if required.

A third Custom Field is being used to indicate if the current time is one of activity allowance or not, but this time a Client Command Line Custom Field.

Client Command Line Custom Fields are stored locally on the device and then this value is available to the server, both for visibility, but can also be used in queries, for Smart Groups.

[![image.png](https://kb.filewave.com/uploads/images/gallery/2024-07/scaled-1680-/PRPwF3Lg4yYn7kOY-image.png)](https://kb.filewave.com/uploads/images/gallery/2024-07/PRPwF3Lg4yYn7kOY-image.png)

<p class="callout warning">Client Command Line Custom Fields can be changed in FileWave Central, but the client value is pushed back to the server the next time the device reports inventory.</p>