# Sample - Set Theme Settings

Setting the background image is not nearly as straight forward as it was in the old Win7 and early Win10 days.  Today you need to create a theme file and apply that to the default user profile.  It's still all possible and scriptable, and this makes for a good step definition where you can do all the scripting on the backend and prompt for an image file in the GUI.

### Step Definition

The step consists of several options, two basics are the content item and scriptName.  These will be hidden and be the "brains" of the step running behind the scenes during the TS. &#x20;

There will be a text box option to fill in the name of the background file, and a content item they can choose which will host the image file for the background.  There is also a checkbox to enable Dark mode, which we'll set to true by default.

<figure><img src="/files/1asV4de6SW1X58364BbB" alt=""><figcaption></figcaption></figure>

Looking at the task sequence editor, it all comes more clear.  The UI makes it pretty clear to the admin adding the step the required information to make the step work.  The name of the png file and the content item in which the png file is located.

<figure><img src="/files/8FryobEs4xLkTUAKeFKb" alt=""><figcaption></figcaption></figure>

That's it, the step defintion does all the hard work in the background using the script that gets called, leveraging the information provided in the UI.

### Task Sequence in Action

Here I've blocked out a couple of areas, the top area shows the Step running and creating the variables based on the step definition, it also downloads the content items into the c:\\\_2P\Content location.\
Later in the log, you see the write-output messages that are from the script, as it logs what is happening.  Another good reason to add a lot of write-output in your scripts, makes for easier troubleshooting later.

<figure><img src="/files/CJswIPl8oPTow6xlNzdo" alt=""><figcaption></figcaption></figure>

Looking at the content it downloaded for that step based on those few first lines, we can see it downloaded the script that needs to run:

<figure><img src="/files/p2xf9KR70sO7iMtjyKe1" alt=""><figcaption></figcaption></figure>

It also downloaded the content item with branding images, including the one specified in the step definition:<br>

<figure><img src="/files/pAAIbdYhta1cy0A3T2oM" alt=""><figcaption></figcaption></figure>

### Script

\[Script] <https://github.com/2pintsoftware/2Pint-DeployR/blob/main/Samples/StepDefinitions/Set-BackgroundImage.ps1>

Here we'll dig into what the script is doing on the backend during the task sequence.  First we have a little logic built in, so if the step was added to the WinPE section of the task sequence, it will exit out nicely with a single message.  Then hopefully if the admin is wondering why it didn't work, they look at the log.  Next we'll gab the variables created by the step definition when it's running in the task sequence.  In this example, there is an extra variable that does not yet exist in the UI, which could be used in a different step definition, or we could modify the UI to allow the admin to enter the URL of the image.  But for now, it's the next three variables that matter, the name of the file, the content item that the file is contained in, and if we're gong to enable Dark Mode.

<figure><img src="/files/FYuN662dS97TKmhCFj6i" alt=""><figcaption></figcaption></figure>

Now we're going to write out the variables, or modify them to what we're going to need later.  Example, we'll take that Boolean for dark mode and convert it into a string "dark" or "light", which is what the theme needs.

<figure><img src="/files/CvdUPbCiZyuy4rcqFW6n" alt=""><figcaption></figcaption></figure>

Now we'll build a function that will create the theme file based on the variables we pass into it...

<figure><img src="/files/Vxfz1koywbUMMlAV3Sk4" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/2sLoN0Spwk5l0FYHTdZK" alt=""><figcaption></figcaption></figure>

At this point, we have a variable that contains the theme file information, and we have the background image that was supplied by the admin in the UI copied into the \_2P\content folder.

Now we finish off the function by creating the OEM Themes folder and creating the theme file inside it.  We also copy the background image to the correct location for the theme file to find.  The script then continues to mount the default user registry hive, and set the theme we just created as the default.

<figure><img src="/files/2kBAXA7FXgakZsz0gGmH" alt=""><figcaption></figcaption></figure>

The script then finishes up with a little reporting, then calling the function to do all that work<br>

<figure><img src="/files/MInsYzh2aaAxDJtVqKu1" alt=""><figcaption></figcaption></figure>

Now, when this step definition is added to your task sequence, the image will be set for your user's background when they logon.&#x20;

<figure><img src="/files/PpiSyhSq5ujTAL8LurUP" alt=""><figcaption></figcaption></figure>


---

# 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://documentation.2pintsoftware.com/deployr/getting-started/creating-a-step-definition/sample-set-theme-settings.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.
