[Windows] Powershell script to launch latest experimental

I wrote a simple powershell script that might not be useful to many people but I thought I’d share it just in case someone else stores different game versions like I do.

When I download a new experimental from the jenkins repository, I don’t overwrite the version I last used but instead keep different versions in their own folders next to each other for safety. This script lets me quickly launch the latest version I have from the desktop.

This is the script:

[code]$scriptPath = split-path -Parent $MyInvocation.MyCommand.Definition

$names = Get-ChildItem $scriptPath
$largest = “”

foreach ($item in $names)
{
if (($item.PSIsContainer)-and ($item.Name -match ("^cataclysmdda-\d+.[A-Z]-\d+")) -and ($largest -lt $item.Name))
{
$largest = $item.Name
}
}

$names = Get-ChildItem $scriptPath$largest

foreach ($item in $names)
{
if ($item.Name -eq “cataclysm-tiles.exe”)
{
$exe = “cataclysm-tiles.exe”
}
elseif ($item.Name -eq “cataclysm.exe”)
{
$exe = “cataclysm.exe”
}
}

Set-Location $scriptPath$largest

& ./$exe
[/code]

Just save this text with the file extension .ps1 (remember you might have to rename it from .ps1.txt if you use default notepad) in the same folder as the experimental folders, for example:

[ul][li]CataclysmDDA[list]
[li]cataclysmdda-0.B-2745[/li]
[li]cataclysmdda-0.C-3045[/li]
[li]cataclysmdda-0.C-3087[/li]
[li]launch-cataclysm.ps1[/li]
[/list][/li][/ul]

[hr]
If you’re not familiar with powershell scripts, executing them isn’t the easiest thing to do (due to “security concerns” on microsoft’s side)
You’ll have to first enable execution of scripts by opening powershell as admin and entering

(this only needs to be set a single time)

To actually execute the script, a simple shortcut to the script won’t work. Instead you’ll need a shortcut to %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -File <full path to the script, with quotes if it contains spaces>

This shortcut will then launch the cataclysm.exe or cataclysm-tiles.exe with the largest version number.