DeathShade
Member
Powershell version to automatically download latest build
I finally got around to writing this today.
A powershell version of this script that as long as you have powershell downloaded you don't need any compilation or other programs.
Note this downloads and launches the file from the directory the .ps1 is stored in
My desktop shortcut looks something like this:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file "C:\KoLmafia\Launch.ps1"
I finally got around to writing this today.
A powershell version of this script that as long as you have powershell downloaded you don't need any compilation or other programs.
Note this downloads and launches the file from the directory the .ps1 is stored in
Code:
#download latest
$loc=(Split-Path -parent $MyInvocation.MyCommand.Definition)
$webclient = New-Object System.Net.WebClient
$results=$webClient.DownloadString("http://builds.kolmafia.us")
$results=$results.substring($results.IndexOf('http://builds.kolmafia.us/KoLmafia-'),80)
$latest=$results.substring(0,$results.indexof('.jar')+4)
$filename=$latest.substring($latest.lastindexof('/')+1)
if (!(Test-Path $loc\$filename)) { $webClient.DownloadFile($latest, "$loc\$filename") }
#cleanup old, leave latest 2
get-childitem $loc\*.jar | sort -desc -prop LastWriteTime | select -skip 2 | del
#launch latest
cd $loc
& $((get-childitem $loc\*.jar | sort -prop LastWriteTime | select -last 1).ToString())
My desktop shortcut looks something like this:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -file "C:\KoLmafia\Launch.ps1"