Skip to content

Instantly share code, notes, and snippets.

@coreequip
Last active February 8, 2022 12:37
Show Gist options
  • Save coreequip/cd90ef1816862c2d24db257a8c1a6ee7 to your computer and use it in GitHub Desktop.
Save coreequip/cd90ef1816862c2d24db257a8c1a6ee7 to your computer and use it in GitHub Desktop.
FS-Launch - a FirstSprit™ launcher

FS-Launch - a FirstSprit™ launcher

FS-Launch is a powershell script to login, download and run a FirstSpirit config file.

Installing

Just copy the script in a folder of your choice.

Setup

  • Open a powershell console (hint: WIN+X)
  • Enter the following command: Read-Host -AsSecureString | ConvertFrom-SecureString | Set-Clipboard
  • At the promt enter your FS password. It will be copied encrypted to your clipboard
  • Replace the string 0123456789YOURSECURESTRING in line 4 with your clipboard content
  • Enter your hostname in line 1
  • Enter your username in line 2

Done.

Running

Just run the fs-launch.cmd file.

Known issues

When windows shows a message that the .cmd file cannot be executed, open the properties of the file and on the bottom check the permission to execute it.

@echo off
powershell -ep bypass -File "%~dp0\%~n0.ps1" %1
timeout 5
$BASEURL = 'your.host.name'
$USERNAME = 'yourusername'
# Generate password string with: Read-Host -AsSecureString | ConvertFrom-SecureString | Set-Clipboard
$PASSWORD = ConvertTo-SecureString '0123456789YOURSECURESTRING'
Write-Host 'Getting launch config ... ' -NoNewline
$form = @{
'login.user' = $USERNAME;
'login.password' = [PSCredential]::new(0, $PASSWORD).GetNetworkCredential().Password;
'login' = 'webnonsso'
}
$firstspirit = $null
$res = Invoke-WebRequest -Uri ('https://{0}/login.jsp' -f $BASEURL) -SessionVariable firstspirit
$null = $res -match '"xsrft" value="(.*?)"'
$form['xsrft'] = $matches[1]
$null = Invoke-WebRequest -Method Post -Uri ('https://{0}/index.jsp' -f $BASEURL) -WebSession $firstspirit -Body $form
$res = Invoke-WebRequest -Uri ('https://{0}/start/FIRSTspirit.jnlp?app=client&locale=en' -f $BASEURL) -WebSession $firstspirit
Write-Host "OK`nStarting FirstSpirit ... " -NoNewline
$launchFile = Join-Path ([IO.Path]::GetTempPath()) ('{0}.fslnch' -f $USERNAME)
Set-Content -Value $res.Content -Path $launchFile
Start-Process -FilePath $launchFile
Start-Sleep 10
Remove-Item $launchFile -Force
Write-Host 'OK'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment