-
-
Save Halkcyon/b9dd802e56e5889a62d1c1d3bc9761e6 to your computer and use it in GitHub Desktop.
Automatically update ArcDps and BuildTemplates from deltaconnected for Guild Wars 2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 2>NUL & powershell -nop -nol -ep bypass "gc -ra '%~f0'|iex" & EXIT /B | |
# ^ boilerplate to execute script from batch context | |
# Update this variable to where you have GW2 installed and named. | |
# This defaults to `C:\Program Files\` | |
[System.IO.FileInfo] $GW2_PATH = "$Env:ProgramFiles\Guild Wars 2\Gw2-64.exe" | |
# This line can be removed if you don't want to pass any arguments. | |
# It does not get used if you already have a | |
# `%APPDATA%\Guild Wars 2\Settings.json` file. | |
# Documentation: | |
# https://wiki.guildwars2.com/wiki/Command_line_arguments | |
$GW2_ARGS = @('/mapLoadinfo', '/bmp', '/autologin', '/fps:60') | |
if (Get-Process -Name $GW2_PATH.Name -ErrorAction SilentlyContinue) { | |
exit | |
} | |
function Start-Gw2() { | |
$startProcessParams = @{ | |
FilePath = $GW2_PATH.FullName | |
} | |
if (-not $(Test-Path -Path "$Env:AppData\Guild Wars 2\Settings.json") -and $GW2_ARGS) { | |
$startProcessParams['ArgumentList'] = $GW2_ARGS | |
} | |
Start-Process @startprocessParams | |
Start-Sleep -Seconds 10 | |
$startProcessParams = @{ | |
FilePath = "$($GW2_PATH.DirectoryName)\addons\taco\GW2TacO.exe" | |
WorkingDirectory = "$($GW2_PATH.DirectoryName)\addons\taco\" | |
} | |
Start-Process @startProcessParams | |
exit | |
} | |
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12 | |
$arcPath = "$($GW2_PATH.DirectoryName)\bin64\d3d9.dll" | |
$arcUri = 'https://www.deltaconnected.com/arcdps/x64/d3d9.dll' | |
$templatesPath = "$($GW2_PATH.DirectoryName)\bin64\d3d9_arcdps_buildtemplates.dll" | |
$templatesUri = 'https://www.deltaconnected.com/arcdps/x64/buildtemplates/d3d9_arcdps_buildtemplates.dll' | |
try { | |
$invokeWebRequestParams = @{ | |
Uri = 'https://www.deltaconnected.com/arcdps/x64/d3d9.dll.md5sum' | |
UseBasicParsing = $true | |
ErrorAction = [System.Management.Automation.ActionPreference]::Stop | |
} | |
$remoteHash = $( | |
@($(Invoke-WebRequest @invokeWebRequestParams).RawContent -split "`n").Where{$_}[-1] -split '\s' | |
)[0] | |
} | |
catch { | |
"Failed to retrieve checksum for ArcDPS: $PSItem" | |
$null = $Host.UI.RawUI.ReadKey() | |
Start-Gw2 | |
} | |
if ($remoteHash.Length -ne 32) { | |
"Bad MD5 checksum from ArcDPS: $remoteHash." | |
$null = $Host.UI.RawUI.ReadKey() | |
Start-Gw2 | |
} | |
#region ArcDPS/BuildTemplates download | |
if (Test-Path -Path $arcPath) { | |
if ($(Get-FileHash -Path $arcPath -Algorithm MD5).Hash -ne $remoteHash) { | |
'ArcDPS is out-of-date.' | |
if (Test-Path -Path "$arcPath.bak") { | |
Remove-Item -Path "$arcPath.bak", "$templatesPath.bak" -Force | |
} | |
Rename-Item -Path $arcPath -NewName "$arcPath.bak" | |
Rename-Item -Path $templatesPath -NewName "$templatesPath.bak" | |
try { | |
Invoke-WebRequest -Uri $arcUri -OutFile $arcPath -ErrorAction Stop | |
Invoke-WebRequest -Uri $templatesUri -OutFile $templatesPath -ErrorAction Stop | |
} | |
catch { | |
Remove-Item -Path $arcPath, $templatesPath -Force -ErrorAction Ignore | |
Rename-Item -Path "$arcPath.bak" -NewName $arcPath | |
Rename-Item -Path "$templatesPath.bak" -NewName $templatesPath | |
"Failed to update ArcDPS: $PSItem Restored old version." | |
$null = $Host.UI.RawUI.ReadKey() | |
Start-Gw2 | |
} | |
'ArcDPS install complete.' | |
} | |
else { | |
'ArcDPS is up-to-date.' | |
} | |
} | |
else { | |
Invoke-WebRequest -Uri $arcUri -OutFile $arcPath | |
Invoke-WebRequest -Uri $templatesUri -OutFile $templatesPath | |
'ArcDPS install complete.' | |
Start-Sleep -Seconds 1 | |
} | |
#endregion | |
Start-Gw2 |
Worked flawlessly - thank you!
Rev#25 - cleaned up batch boilerplate and am planning on adding taco update support.
Thanks for the gist, I adapted it because I set Tac0 in another folder, here is what I've done, if you'd like to add it :)
# Update this variable to where you have GW2 installed and named.
# This defaults to `C:\Program Files\`
[System.IO.FileInfo] $GW2_PATH = "D:\Guild Wars 2\Gw2-64.exe"
# Update this variable to where you have TACO located.
# This defaults to `C:\Program Files\Guild Wars 2\addons\taco\`
$TACO_PATH = "C:\Program Files\Guild Wars 2\addons\taco\"
or use
$TACO_PATH = "$($GW2_PATH.DirectoryName)\addons\taco\"
and
function Start-Gw2() {
$startProcessParams = @{
FilePath = $GW2_PATH.FullName
}
if (-not $(Test-Path -Path "$Env:AppData\Guild Wars 2\Settings.json") -and $GW2_ARGS) {
$startProcessParams['ArgumentList'] = $GW2_ARGS
}
Start-Process @startprocessParams
Start-Sleep -Seconds 10
$startProcessParams = @{
FilePath = "$($TACO_PATH)GW2TacO.exe"
WorkingDirectory = "$($TACO_PATH)"
}
Start-Process @startProcessParams
exit
}
Feel free to reach me :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was getting a "Could not establish trust relationship for the SSL/TLS..." error when calling
Invoke-WebRequest
with a https site. I need to extend your script with this code beforeInvoke-WebRequest
:Source: https://stackoverflow.com/a/38729034
I had to use the
-UseBasicParsing
parameter forInvoke-WebRequest
as well and now your script is working in my system without any problem. Thanks for your script!