| # KPScript - KPS Script Files How to use KPS script files to automate KeePass 2.x.

KPS script files are a lot more powerful than single command operations, but are also more complicated. You need to have heavy experience in C# programming and the KeePass 2.x internals. Within KPS files you can do everything that KeePass does.

What are KPS files?

KPS files are C# files that are loaded, compiled and executed by the `KPScript.exe` program. Within the script file, you got full access to the KeePass internals.

The main differences to "normal" C# files are:

- No need for `using` directives.
- No need to add a reference to the KeePass assembly.
- No need to write a wrapper class. Simply start with `Main()`. The complete script file is embedded in a static class.

Here's the famous Hello World program as KPS script:

    public static void Main()
    {
    	MessageService.ShowInfo("Hello World!");
    }

For the most important namespaces, KPScript automatically adds `using` directives at the start of the file before compiling it. `MessageService` for example is located in `KeePassLib.Utility`, but as it's included automatically by KPScript, you can use it directly.

Executing a KPS file:

To run a KPS file, you simply pass it to KPScript:

    KPScript.exe C:\KeePass\MyScriptFile.kps

It is important that the file extension is `.kps`, otherwise KPScript won't recognize the file and will interpret it as database for single command operations.