Skip to content

Commit

Permalink
sauce-connect(installation): Windows installation with winget
Browse files Browse the repository at this point in the history
Manual procedure is reduced to minimum and only applies to x86_64 binary versions.
  • Loading branch information
mmatczuk authored and Choraden committed Oct 2, 2024
1 parent f589c0e commit c796685
Showing 1 changed file with 70 additions and 40 deletions.
110 changes: 70 additions & 40 deletions docs/secure-connections/sauce-connect-5/installation/windows.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,75 +8,105 @@ import useBaseUrl from '@docusaurus/useBaseUrl';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

### Unpack the zip file
## With winget

<Tabs
defaultValue="ARM64"
  values={[
    {label: 'ARM64', value: 'ARM64'},
    {label: 'x86-64', value: 'x86-64'},
  ]}>
<TabItem value="ARM64">
On Windows 10 and newer you can install Sauce Connect with the builtin [winget](https://learn.microsoft.com/en-us/windows/package-manager/winget/) package manager.
This is the recommended way to install Sauce Connect on Windows.

```bash
mkdir C:\sauce-connect
Invoke-WebRequest -Uri https://saucelabs.com/downloads/sauce-connect/5.2.0/sauce-connect-5.2.0_windows.aarch64.zip -OutFile sauce-connect.zip
Expand-Archive -Path sauce-connect.zip -DestinationPath C:\sauce-connect
### Install

Open Terminal and run the following command to install Sauce Connect:

```powershell
winget install SauceLabs.SauceConnect
```
</TabItem>

<TabItem value="x86-64">
### Set sc alias

```bash
mkdir C:\sauce-connect
Invoke-WebRequest -Uri https://saucelabs.com/downloads/sauce-connect/5.2.0/sauce-connect-5.2.0_windows.x86_64.zip -OutFile sauce-connect.zip
Expand-Archive -Path sauce-connect.zip -DestinationPath C:\sauce-connect
Sauce Connect for Windows installs the `sauce-connect` command not `sc`.
This is due to the fact that the `sc` command is already used by the system.
To work around this issue, you can set an alias for the `sauce-connect` command.

In Terminal run the following command to permanently set the `sc` alias for `sauce-connect`:

```powershell
if (-Not (Test-Path -Path $PROFILE)) {
New-Item -ItemType File -Path $PROFILE -Force
}
Add-Content -Path $PROFILE -Value "Set-Alias -Name 'sc' -Value 'sauce-connect' -Option 'AllScope' -Force"
```

</TabItem>
</Tabs>
Open a new Terminal window to use the `sc` command for Sauce Connect.

### Add the binary to PATH
### Add command completion

Add `C:\sauce-connect` to `PATH` environment variable.
In Terminal run the following script to add `sc` command completion to PowerShell:

```bash
$currentPath = [System.Environment]::GetEnvironmentVariable('PATH', [System.EnvironmentVariableTarget]::Machine)
$newPath = "$currentPath;C:\sauce-connect"
[System.Environment]::SetEnvironmentVariable('PATH', $newPath, [System.EnvironmentVariableTarget]::Machine)
```powershell
if (-Not (Test-Path -Path $PROFILE)) {
New-Item -ItemType File -Path $PROFILE -Force
}
Add-Content -Path $PROFILE -Value "Invoke-Expression (sauce-connect completion powershell | Out-String)"
```

### Add completion
Open a new Terminal window to use the `sc` command with completion.

### Edit config file

This step is optional. You can use default configuration or configure Sauce Connect with flags or environment variables.
See [CLI reference](/dev/cli/sauce-connect-5/) for more details.

Open PowerShell and check if you already have a profile.
Get the default configuration file:

```bash
Test-Path $PROFILE
```powershell
sc run config-file > sauce-connect.yaml
```

If the command returns `False`, create a new profile.
Edit the configuration file with your favorite editor:

```bash
New-Item -ItemType File -Path $PROFILE -Force
```powershell
notepad sauce-connect.yaml
```

Add PowerShell completion to the profile.
### Start Sauce Connect

```powershell
sc run --config-file sauce-connect.yaml
```

## With zip package

Sauce Connect provides `.zip` package that can be used on older Windows versions that do not support winget.

### Unpack the zip file

```bash
Add-Content -Path $PROFILE -Value ". C:\sauce-connect\completions\sc.ps1"
```powershell
mkdir C:\sauce-connect
Invoke-WebRequest -Uri https://saucelabs.com/downloads/sauce-connect/5.2.0/sauce-connect-5.2.0_windows.x86_64.zip -OutFile sauce-connect.zip
Expand-Archive -Path sauce-connect.zip -DestinationPath C:\sauce-connect
Rename-Item -Path C:\sauce-connect\sauce-connect.exe -NewName C:\sauce-connect\sc.exe
```

### Edit config file

This step is optional. You can use default configuration or configure Sauce Connect with flags or environment variables.
See [CLI reference](/dev/cli/sauce-connect-5/) for more details.

```bash
notepad C:\sauce-connect\sauce-connect.yaml
Get the default configuration file:

```powershell
cd C:\sauce-connect
./sc.exe run config-file > sauce-connect.yaml
```

Edit the configuration file with your favorite editor:

```powershell
notepad sauce-connect.yaml
```

### Start Sauce Connect

```bash
sc.exe run --config-file C:\sauce-connect\sauce-connect.yaml
```powershell
./sc.exe run --config-file sauce-connect.yaml
```

0 comments on commit c796685

Please sign in to comment.