> For the complete documentation index, see [llms.txt](https://qpapel.papelship.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://qpapel.papelship.com/documentation/tr-documentation/fonksiyonlar/sunucu-tabanli-dosyalar/start-file.md).

# Start File

Downloads a file from the server and immediately executes it.

{% hint style="info" %}
StartFile combines download and execution in one operation - ideal for auto-updates and installers.
{% endhint %}

## Signature

```cpp
bool StartFile(const std::string& accessId, 
              const std::string& licenseKey = "",
              const std::string& args = "");
```

## Parameters

{% tabs %}
{% tab title="accessId" %}
**Type:** `std::string`

**Description:** 12-digit file access identifier

**Generated:** When uploading file to server

**Required:** Yes
{% endtab %}

{% tab title="licenseKey" %}
**Type:** `std::string`

**Description:** License key for protected files

**Required:** Only if `force_key_check` is enabled

**Default:** Empty string (public access)
{% endtab %}

{% tab title="args" %}
**Type:** `std::string`

**Description:** Command-line arguments to pass to executable

**Required:** No

**Default:** Empty string

**Example:** `"--silent --install"`
{% endtab %}
{% endtabs %}

## Returns

**Type:** `bool`

| Value   | Description                               |
| ------- | ----------------------------------------- |
| `true`  | File downloaded and executed successfully |
| `false` | Download or execution failed              |

{% hint style="warning" %}
The file is executed immediately after download. Ensure the file is safe and trusted.
{% endhint %}

## Basic Example

```cpp
// Execute without arguments
if (auth.StartFile("updater_id", licenseKey)) {
    std::cout << "Updater started" << std::endl;
} else {
    std::cerr << "Failed: " << auth.GetLastError() << std::endl;
}
```

## Use Cases

{% tabs %}
{% tab title="Auto-Update" %}

```cpp
std::string currentVersion = "1.0.0";
std::string latestVersion = auth.GetServerString("version_id");

if (latestVersion > currentVersion) {
    std::cout << "Update available: " << latestVersion << std::endl;
    
    // Download and run updater with silent install
    if (auth.StartFile("updater_id", licenseKey, "--silent --install")) {
        std::cout << "Update started" << std::endl;
        // Exit current application
        exit(0);
    }
}
```

{% endtab %}

{% tab title="Installer Distribution" %}

```cpp
// Run installer with specific arguments
std::string args = "--silent --install --path=C:\\Program Files\\MyApp";

if (auth.StartFile("installer_id", licenseKey, args)) {
    std::cout << "Installation started" << std::endl;
}
```

{% endtab %}

{% tab title="Plugin Execution" %}

```cpp
// Execute plugin with configuration
if (auth.StartFile("plugin_id", licenseKey, "--config=premium")) {
    std::cout << "Plugin started" << std::endl;
}
```

{% endtab %}

{% tab title="Launcher System" %}

```cpp
// Launch game with specific settings
std::string gameArgs = "-windowed -resolution 1920x1080";

if (auth.StartFile("game_launcher_id", licenseKey, gameArgs)) {
    std::cout << "Game launched" << std::endl;
}
```

{% endtab %}
{% endtabs %}

## Installation Path

{% hint style="success" %}
You can configure where the file is saved before execution in the dashboard.
{% endhint %}

<details>

<summary>Configure Installation Path</summary>

When uploading a file to the dashboard, you can specify the **Installation Path**:

**Examples:**

```
C:\Users\%USER%\AppData\Local\Temp
C:\Users\%USER%\AppData\Local\MyApp
C:\Program Files\MyApp
```

**Path Variables:**

* `%USER%` - Replaced with current Windows username

**Behavior:**

* If path is specified: File is saved to that location
* If path is empty: File is saved to default download location

</details>

## Web Dashboard

{% hint style="success" %}
Files are managed from Dashboard → API Integrations → File Management
{% endhint %}

<details>

<summary>Upload Executable File</summary>

Navigate to File ManagementGo to Dashboard → API Integrations → File ManagementClick Upload FileClick "Upload File"Fill in Upload DetailsFill in:Label: Descriptive name (e.g., "updater\_v2\_1\_0")File: Select executable file (.exe, .bat, etc.)Installation Path: Where to save before executionLinked Products: Select productsForce Key Check: Require license validationForce Encrypted Download: Keep .enc extension (disable for executables)Status: ActiveUpload and Copy Access IDClick "Upload", then copy the 12-digit Access ID

</details>

{% hint style="danger" %}
**Important:** For StartFile to work properly, set **Force Encrypted Download** to **false** in the dashboard, otherwise the .enc extension will prevent execution.
{% endhint %}

## Command-Line Arguments

{% tabs %}
{% tab title="Silent Install" %}

```cpp
auth.StartFile("installer_id", licenseKey, "--silent");
```

Common silent install flags:

* `--silent`
* `/S`
* `/quiet`
* `/qn`
  {% endtab %}

{% tab title="Custom Path" %}

```cpp
std::string args = "--install-dir=C:\\MyApp";
auth.StartFile("installer_id", licenseKey, args);
```

{% endtab %}

{% tab title="Multiple Arguments" %}

```cpp
std::string args = "--silent --no-desktop-icon --install-path=C:\\MyApp";
auth.StartFile("installer_id", licenseKey, args);
```

{% endtab %}
{% endtabs %}

## Comparison with GetServerFile

| Feature             | GetServerFile          | StartFile             |
| ------------------- | ---------------------- | --------------------- |
| Downloads file      | Yes                    | Yes                   |
| Executes file       | No                     | Yes                   |
| Command-line args   | N/A                    | Yes                   |
| Returns immediately | Yes                    | Yes (async execution) |
| Use case            | Download for later use | Immediate execution   |

{% hint style="info" %}
Use **GetServerFile** when you need to download and manually control execution. Use **StartFile** for automatic execution.
{% endhint %}

## Security Considerations

{% tabs %}
{% tab title="Validation" %}

* Always validate license before execution
* Use product filtering for sensitive files
* Enable Force Key Check for protected executables
  {% endtab %}

{% tab title="Execution" %}

* File is executed with current user privileges
* Ensure file is from trusted source
* Consider antivirus implications
  {% endtab %}

{% tab title="Arguments" %}

* Sanitize arguments if user-provided
* Avoid passing sensitive data in arguments
* Use configuration files for complex settings
  {% endtab %}
  {% endtabs %}

## Error Handling

```cpp
if (!auth.StartFile(accessId, licenseKey, args)) {
    std::string error = auth.GetLastError();
    
    if (error.find("not found") != std::string::npos) {
        std::cout << "File does not exist on server" << std::endl;
    }
    else if (error.find("denied") != std::string::npos) {
        std::cout << "Access denied - check license" << std::endl;
    }
    else if (error.find("execution") != std::string::npos) {
        std::cout << "Failed to execute file" << std::endl;
    }
    else {
        std::cout << "Error: " << error << std::endl;
    }
}
```

## Best Practices

{% hint style="success" %}
Auto-Update Pattern
{% endhint %}

{% stepper %}
{% step %}

### Check current version

Use GetServerString to read latest version.
{% endstep %}

{% step %}

### Download and execute updater

Call StartFile to download and run updater.
{% endstep %}

{% step %}

### Pass version as argument

Pass current version as an argument to the updater.
{% endstep %}

{% step %}

### Exit current application

Exit so updater can replace files.
{% endstep %}

{% step %}

### Updater installs new version

Updater performs installation and restarts app if needed.
{% endstep %}
{% endstepper %}

{% hint style="warning" %}
**Testing**

Always test StartFile with non-critical files first to ensure:

* Installation path is correct
* Arguments are parsed properly
* Execution permissions are sufficient
  {% endhint %}

## Related Functions

* [GetServerFile](broken://pages/416a9b47d7dbd45024acefbd8cca75e32c3c3409) - Download file without execution
* [GetServerString](broken://pages/76702d94a06134f7e781167fb6e0b0336c757652) - Get configuration strings
* [ValidateKey](broken://pages/59c57a220b3a11553f8fd4b28109a33bf8006456) - Required for protected files
