# Executing scripts

### Preface

You can execute scripts on a per-client basis directly on the clients page. By selecting "scripts" on top navigation, you can execute scripts on many clients in parallel.&#x20;

![Two options for script execution](https://1574570054-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MekeI9EovpQqbUTQSdM%2F-MgfcSmFdxikO59c2iij%2F-MgfvKmc3HBDcD04J6Aw%2Fimage.png?alt=media\&token=cb269f5d-c886-4c49-97f5-9c3c8cf62252)

### On Windows

Learn, from this video, how to execute PowerShell scripts on Windows machines (servers or desktop) – on a single machine and on multiple targets in parallel.

{% embed url="<https://vimeo.com/639533275>" %}
Execute PowerShell scripts with RPort
{% endembed %}

The video show how to install 7zip and notepad++ fully unattended with RPport using the following lines of PowerShell.

{% code title="install-7zip.ps1" %}

```powershell
iwr https://7-zip.org/a/7z1900-x64.msi -OutFile 7z1900-x64.msi
msiexec /i 7z1900-x64.msi /quiet /qn /norestart
sleep 10
Remove-Item -Path 7z1900-x64.msi -Force
if (Test-Path "C:\Program Files\7-Zip\7z.exe") {
    Write-Host "7zip installed"
}
```

{% endcode %}

{% code title="install-notepad++.ps1" %}

```powershell
if (Test-Path "C:\Program Files\Notepad++\notepad++.exe" -PathType leaf) {
    Write-Host "Notepad++ is already installed."
} 
else {
    cd $env:Temp
    iwr https://notepad-plus-plus.org/repository/7.x/7.0/npp.7.Installer.x64.exe -OutFile npp.7.Installer.x64.exe
    .\npp.7.Installer.x64.exe /S
    sleep 10
    rm npp.7.Installer.x64.exe -Force
    New-Item -ItemType SymbolicLink -Path "C:\Users\Public\Desktop\" -Name "notepad++.lnk" -Value "C:\Program Files\Notepad++\notepad++.exe"
    Write-Host "Notepad++ installed"
}
```

{% endcode %}

### On Linux

Type in the content of a script. You can use a regular shebang as first line like `#!/bin/bash` or `#!/usr/bin/env python3`.&#x20;

![Executing Python](https://1574570054-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MekeI9EovpQqbUTQSdM%2F-MiVMn09MQItUk-sDJmV%2F-MiVOOR2kTpMnNVSNLe1%2Fimage.png?alt=media\&token=72f84401-90be-47a8-b7fe-af63ad5e878a)

{% hint style="success" %}
If no shebang is given, `/bin/sh` is used to execute your script.
{% endhint %}

### Custom script interpreters

Starting with version 0.6.0 you can execute your scripts with an interpreter.&#x20;

Either enter the full path to the interpreter, or register available interpreters in the client's `rport.conf` file.

&#x20;To register a script interpreter on the `rport.conf` file on the client and append a list of available interpreters. After restarting the client, they get available on the user interface.

<div align="left"><img src="https://1574570054-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MekeI9EovpQqbUTQSdM%2Fuploads%2FwlUW7H4A9AsresqqGA6D%2Fimage.png?alt=media&#x26;token=27609f3a-bd4d-4912-b568-a8c28d2b472a" alt="Execute with any interpreter"> <img src="https://1574570054-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MekeI9EovpQqbUTQSdM%2Fuploads%2FYpTdOwwDforyf0Pg9CvP%2Fimage.png?alt=media&#x26;token=4b229c6d-44d2-4923-b04f-af26e29fd462" alt="Register custom interpreters"></div>
