# Using Pre-Install Scripts in a Patch My PC Cloud Deployment

*Applies to: Patch My PC Cloud*

A *Pre-Install Script* is a script that can be run before the installer runs.

To add a Pre-Install script:

1. Click **Add** beside the **Pre-Install** option.

<figure><img src="https://3773699522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX7dvS0r_4fc0AikgJS%2Fuploads%2FoPdAL6hnZWF05pNF3jNK%2Fimage.png?alt=media&#x26;token=497aee4b-4fac-45b0-9b9c-ab117a7dd9aa" alt="Clicking “Add” beside the “Pre-Install” option" width="419"><figcaption></figcaption></figure>

The **Add Pre-Install Script** page is shown, highlighting that the default **Script Format** is **.ps1**, with built-in support for PSADT functions.&#x20;

<figure><img src="https://3773699522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX7dvS0r_4fc0AikgJS%2Fuploads%2FC4f4sH2H2ZfTGPmxMvWZ%2Fimage.png?alt=media&#x26;token=df5b0ed5-7b2e-48b7-affd-cfe673887a81" alt="&#x27;Add Pre-Install Script&#x27; page highlighting that the default Script Format is .ps1, with built-in support for PSADT functions. " width="563"><figcaption></figcaption></figure>

2. To import an existing script, click **Import,** then browse to the location containing the script and select it.

<figure><img src="https://3773699522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX7dvS0r_4fc0AikgJS%2Fuploads%2FmSTTRoMl8dD5t8MqVTHh%2Fimage.png?alt=media&#x26;token=270ded24-8ec4-462b-a1b5-9dfcc5e88930" alt="Clicking &#x27;Import&#x27; to import an existing script" width="563"><figcaption></figcaption></figure>

The **Script Name** field is populated with the filename of the script selected, and the **Add Pre-Install Script** page is populated with the imported script.

<figure><img src="https://3773699522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX7dvS0r_4fc0AikgJS%2Fuploads%2F3grpzmk7nIfUdVwdCrvq%2Fimage.png?alt=media&#x26;token=c78395fd-caa4-4bf6-8d30-50cae8000127" alt="The &#x27;Add Pre-Install Script&#x27; page is populated with the imported script." width="563"><figcaption></figcaption></figure>

3. To manually add a script, enter a unique name for the script in the **Script Name** field.

<figure><img src="https://3773699522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX7dvS0r_4fc0AikgJS%2Fuploads%2F7wBvsEiGRG9STNOej0q0%2Fimage.png?alt=media&#x26;token=ad8ea8da-ad46-4bea-bcbb-bc302fa64337" alt="Entering a unique name for the script in the &#x27;Script Name&#x27; field" width="563"><figcaption></figcaption></figure>

4. Select the type of script from the **Script Format** dropdown.

<figure><img src="https://3773699522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX7dvS0r_4fc0AikgJS%2Fuploads%2FqqKYT0zC9ZnnGcqRlJHn%2Fimage.png?alt=media&#x26;token=554d580d-5312-4f49-9e63-fb5dd1fe72e4" alt="Selecting the type of script from the &#x27;Script Format&#x27; dropdown." width="563"><figcaption></figcaption></figure>

5. In the script editor, type your script.

<figure><img src="https://3773699522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX7dvS0r_4fc0AikgJS%2Fuploads%2FKYpwIC1xyqMRlQ8vczu8%2Fimage.png?alt=media&#x26;token=54640ce6-3104-43e9-b387-429621e473a2" alt="Typing your script in the Script Editor" width="563"><figcaption></figcaption></figure>

{% hint style="info" %}
**Note**

We currently have a limit of 50,000 characters per script. Use the **Number of characters used** counter to keep track of the number of characters you’ve entered in the script editor.
{% endhint %}

{% hint style="success" %}
**Tip**

Under the script editor, we include example syntax to help you understand the required syntax for referencing any additional files you've uploaded, which updates depending on the **Script Format** selected.&#x20;
{% endhint %}

6. In the **Arguments** field, enter any arguments you want to provide to the script.

<figure><img src="https://3773699522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX7dvS0r_4fc0AikgJS%2Fuploads%2FLuAoY66r0nCQER9y4BKf%2Fimage.png?alt=media&#x26;token=daa1836e-e109-4e92-b86b-92ef892359a7" alt="Entering any arguments you want to provide to the script by specifying them in the &#x27;Arguments&#x27; field" width="563"><figcaption></figcaption></figure>

{% hint style="success" %}
**Tip**

You can use variable names as arguments, provided they are enclosed by percentage signs (`%`). We provide common variables under this field, which you can add by clicking the plus (+) symbol or relevant variable name.
{% endhint %}

{% hint style="danger" %}
**Important**

Using script Arguments is currently unsupported when deploying an app to macOS.

Also, if you add any PSADT scripts to your deployments, you need to ensure .NET version 4.7.2 is installed on any devices to which this app will be deployed.
{% endhint %}

7. Check the **Don’t attempt software update if the pre-script returns an exit code other than 0 or 3010** checkbox if you don’t want the app to be installed if the pre-script returns an exit code other than **0** or **3010**.<br>

   If you do not check this checkbox, we will attempt to install the app regardless of the exit code returned by the pre-install script.

<figure><img src="https://3773699522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX7dvS0r_4fc0AikgJS%2Fuploads%2FEqh5V9sPtyNpv3vVasft%2Fimage.png?alt=media&#x26;token=9dabedde-99c4-418f-998f-c4f5102e0fe2" alt="Checking the &#x27;Don’t attempt software update if the pre script returns an exit code other than 0 or 3010&#x27; checkbox" width="563"><figcaption></figcaption></figure>

8. Check the **Run the pre-update script before performing any auto-close or skip process checks** checkbox if you want to run the pre-install script before the conflicting process notification is displayed (if relevant).\
   \
   If you do not check this checkbox, we will run the pre-install script after the conflicting process notification.

<figure><img src="https://3773699522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX7dvS0r_4fc0AikgJS%2Fuploads%2FGgiCVecFEnpu9Bn3RTh6%2Fimage.png?alt=media&#x26;token=1dd01abc-76e0-4f6a-9d2f-d6f7b2e1a4de" alt="Checking the &#x27;Run the pre-update script before performing any auto-close or skip process checks&#x27; checkbox" width="563"><figcaption></figcaption></figure>

9. Click **Save** to save your script.

<figure><img src="https://3773699522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX7dvS0r_4fc0AikgJS%2Fuploads%2FkBA3VAVV3CbvM8rZwJoj%2Fimage.png?alt=media&#x26;token=a1c12301-f077-4e62-9da2-c0fd69013317" alt="Clicking &#x27;Save&#x27; to save your script." width="563"><figcaption></figcaption></figure>

The **Configurations** tab is re-displayed with the name of the configured script beside it.

<figure><img src="https://3773699522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MX7dvS0r_4fc0AikgJS%2Fuploads%2FshVV3eWWXUY5CmvOOzWD%2Fimage.png?alt=media&#x26;token=2ace588c-82f0-40c3-b8eb-d2f17e6b19f3" alt="“Configurations” tab re-displayed with the name of the configured script beside it" width="416"><figcaption></figcaption></figure>

{% hint style="success" %}
**Tip**

You can click **Edit** to edit a script or its settings. You can also click the red “`x`” beside a script to delete it.
{% endhint %}

## Next Steps

If you do not want to configure any additional settings, click **Next** to move to the [Assignments](https://docs.patchmypc.com/patch-my-pc-cloud/deployments/deploy-app/assignments-tab) tab.

Otherwise, navigate to the relevant tool to configure the required settings, which are explained in the relevant section.


---

# 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.patchmypc.com/patch-my-pc-cloud/deployments/deploy-app/configurations-tab/additional-tools/scripts/pre-install-scripts.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.
