# Automating with Windows Task

To set up a scheduled task in Windows to run a specific Keeper Commander CLI command on a scheduled basis, you can use the Task Scheduler tool.

In the below example, we'll re-generate a password in the vault on a daily basis.

{% stepper %}
{% step %}
**Install**

[Install Keeper Commander](/en/keeperpam/commander-cli/commander-installation-setup/installation-on-windows.md) for Windows
{% endstep %}

{% step %}
**Login**

Login to Commander by launching the application. For example:

```
server US
login email@company.com
```

{% endstep %}

{% step %}
**Enable Persistent Login**

After login, set up persistent login so that the command can execute from Task Scheduler.

As an example, the below commands will enable "Stay Logged In" for 30 days:

```
this-device register
this-device persistent-login on
this-device ip-auto-approve on
this-device timeout 30d
quit
```

To exit the shell session, type `quit` but **don't** type `logout`. Logout will expire the session and the automations won't work.

To confirm that persistent login is working, execute Commander again and it will automatically login to the shell
{% endstep %}

{% step %}
**Create a Record**

From the command line, we'll create a quick record with a random password.

{% code overflow="wrap" %}

```
record-add -t "Test Record" password=$GEN --record-type=login
```

{% endcode %}

If you have the web vault or other Keeper vault opened, you'll see the record appear.
{% endstep %}

{% step %}
**Open Task Scheduler**

* Press `Win + R` to open the Run dialog.
* Type `taskschd.msc` and press Enter. This opens the Task Scheduler.
  {% endstep %}

{% step %}
**Create a Basic Task**

* In the Task Scheduler, click on the **"Create Basic Task..."** option on the right side.
* Enter a name and description for your task, such as "Daily Keeper Commander Task".
* Click **Next**.
  {% endstep %}

{% step %}
**Set the Trigger**

* Choose the "Daily" option and click **Next**.
* Set the start date and time for the task to run. Ensure the recurrence is set to "1 day" to repeat the task daily.
* Click **Next**.
  {% endstep %}

{% step %}
**Set the Action**

* Choose the "Start a program" option and click **Next**.
* In the "Program/script" field, enter the path to your Keeper Commander executable, for example:

{% code overflow="wrap" %}

```
"C:\Program Files (x86)\Keeper Commander\keeper-commander.exe"
```

{% endcode %}

* In the "Add arguments (optional)" field, enter your Keeper Commander CLI command. For example:

```perl
record-update -r "Test Record" password=$GEN
```

{% endstep %}

{% step %}
**Finish the Task**

* Click **Next** to review the details of your task.
* Click **Finish** to create the task.
* To make sure the command works, select the Task and click "Run" on the right side.
  {% endstep %}
  {% endstepper %}

### Summary

In this particular example, the password will rotate from the Keeper vault and you'll see this occur in realtime across all logged-in vault clients. Another example is running a security audit report, such as:

```
security-audit-report --output c:\path\to\file
```

Any feature or capability of the end-user vault or Admin Console can be automated this way. Take a look at all the Keeper Commander [commands](/en/keeperpam/commander-cli/command-reference.md) available.

To expand upon this use case, you would likely want to set up a Batch file and execute the batch of commands instead of adding them directly on the CLI arguments. More information about batch mode commands can be found [here](/en/keeperpam/commander-cli/commander-installation-setup.md#batch-mode-through-stdin).


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.keeper.io/en/keeperpam/commander-cli/commander-installation-setup/configuration/automating-with-windows-task.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
