Skip to content

Instantly share code, notes, and snippets.

@Deshke
Forked from OneFaced/UpdateArcDps.cmd
Created October 3, 2017 06:36
Show Gist options
  • Save Deshke/0f6b8939ba2db90f19639c3d1273eb2f to your computer and use it in GitHub Desktop.
Save Deshke/0f6b8939ba2db90f19639c3d1273eb2f to your computer and use it in GitHub Desktop.
Automatically Update ArcDps for GuildWars 2
#Modify as required. Points to the default install location
$GW2Path = "C:\Program Files\Guild Wars 2\"
#Don't change these paths unless arc does
$md5sum = 'https://www.deltaconnected.com/arcdps/x64/d3d9.dll.md5sum'
$d3d9 = 'https://www.deltaconnected.com/arcdps/x64/d3d9.dll'
$bt = 'https://www.deltaconnected.com/arcdps/x64/buildtemplates/d3d9_arcdps_buildtemplates.dll'
#And this one unless ANet does
$gw = 'Gw2-64'
function Get-ArcDps
{
write-host 'Downloading ArcDps'
$d3d9Temp = New-TemporaryFile
Invoke-WebRequest -Uri $d3d9 -OutFile $d3d9Temp.FullName
Copy-Item $d3d9Temp.FullName "$($GW2Path)\bin64\d3d9.dll" -Force
Remove-Item $d3d9Temp.FullName -Force
$btTemp = New-TemporaryFile
Invoke-WebRequest -Uri $bt -OutFile $btTemp.FullName
Copy-Item $btTemp.FullName "$($GW2Path)\bin64\d3d9_arcdps_buildtemplates.dll" -Force
Remove-Item $btTemp.FullName -Force
write-host 'Completed ArcDps install'
}
function Invoke-ArcDpsCheck
{
$date = (Get-Date -format "MM-dd-yyyy")
if((Get-Process $gw -EA 0).Count -gt 0)
{
Exit
}
$ignoreCase = [System.StringComparison]::InvariantCultureIgnoreCase
$md5Temp = New-TemporaryFile
Invoke-WebRequest -Uri $md5sum -OutFile $md5Temp.FullName
$md5Hash = Get-Content $md5Temp
$md5Hash = $md5Hash.Substring(0,$md5Hash.IndexOf(' '))
$fileExists = Test-Path "$($GW2Path)\bin64\d3d9.dll"
if($fileExists)
{
$md5D3d9m = Get-FileHash "$($GW2Path)\bin64\d3d9.dll" -Algorithm MD5
if(!$md5D3d9m.Hash.Equals($md5Hash,$ignoreCase))
{
Write-Host 'ArcDps is out of date'
Rename-Item "$($GW2Path)\bin64\d3d9.dll" -NewName "$($GW2Path)\bin64\d3d9.$date" -Force
try
{
Rename-Item "$($GW2Path)\bin64\d3d9_arcdps_buildtemplates.dll" -NewName "$($GW2Path)\bin64\d3d9_arcdps_buildtemplates.$date" -Force
}
catch {}
Get-ArcDps
}
else
{
write-host 'ArcDps is up to date'
}
}
else
{
Get-ArcDps
}
}
Invoke-ArcDpsCheck
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment