Skip to content

Instantly share code, notes, and snippets.

@OneFaced
Last active April 5, 2022 16:00
Show Gist options
  • Save OneFaced/764f9c5c7bef1c49a31d928c223bcb24 to your computer and use it in GitHub Desktop.
Save OneFaced/764f9c5c7bef1c49a31d928c223bcb24 to your computer and use it in GitHub Desktop.
GuildWars 2 ArcDps Update Script
REM <#
@echo off
copy UpdateArcDps.cmd UpdateArcDps.ps1 >NUL
PowerShell.exe -ExecutionPolicy Unrestricted -NoProfile -Command "&{Set-Alias REM Write-Host; .\UpdateArcDps.ps1}"
del UpdateArcDps.ps1
exit
REM #>
#MakeCDDVDAgain (so toxic!)
#T4 Purgatory, T1 Pop
<# ---- Command Line Arguments ----
Add any commandline arguments you need here separated by a comma and encloded in single quotes
List of arguments available at https://wiki.guildwars2.com/wiki/Command_line_arguments
E.g.: $arguments = '-clientport 80','-maploadinfo'
#>
$arguments = '-autologin','-maploadinfo'
<# ---- GuildWars 2 Path ----
Modify as required. Points to the default install location
You can use environment variables here or absolute paths, e.g. E:\gw2
#>
$GW2Path = "$env:ProgramFiles\Guild Wars 2\"
<# ---- GuildWars 2 Executable Name
#This is the default executable name. Adjust as required. Do not include the .exe extension
#>
$gw = 'Gw2-64'
#Don't change these paths unless arc does
$md5Uri = 'https://www.deltaconnected.com/arcdps/x64/d3d9.dll.md5sum'
$d3d9Uri = 'https://www.deltaconnected.com/arcdps/x64/d3d9.dll'
function Start-GW2
{
Write-Verbose 'Starting GuildWars 2...'
if($arguments.Length -lt 1)
{
Start-Process -FilePath "$($GW2Path)\$($gw).exe"
}
else
{
Start-Process -FilePath "$($GW2Path)\$($gw).exe" -ArgumentList $arguments
}
}
function Get-ArcDps
{
Write-Verbose 'Downloading ArcDps'
$d3d9Response = Invoke-WebRequest -Uri $d3d9Uri
Set-Content -Path "$($GW2Path)\bin64\d3d9.dll" -Encoding Byte -Value $d3d9Response.Content
Write-Verbose 'Completed ArcDps install'
Start-GW2
}
function Invoke-ArcDpsCheck
{
if((Get-Process $gw -ErrorAction 0).Count -gt 0)
{
Exit
}
$fileExists = Test-Path "$($GW2Path)\bin64\d3d9.dll"
if($fileExists)
{
$currD3d9 = Get-FileHash "$($GW2Path)\bin64\d3d9.dll" -Algorithm MD5
try
{
$md5response = Invoke-WebRequest -Uri $md5Uri
}
catch {
Write-Verbose 'Failed to download MD5 sum'
Start-GW2
Exit
}
if(!$currD3d9.Hash.Equals(($md5response.ToString().Split(" ",[System.StringSplitOptions]::RemoveEmptyEntries)[0]),
[System.StringComparison]::InvariantCultureIgnoreCase))
{
Write-Verbose 'ArcDps is out of date'
Copy-Item "$($GW2Path)\bin64\d3d9.dll" -Destination "$($GW2Path)\bin64\d3d9_old.bak" -Force
Get-ArcDps
}
else
{
Write-Verbose 'ArcDps is up to date'
Start-GW2
}
}
else
{
Get-ArcDps
}
}
Invoke-ArcDpsCheck
@OneFaced
Copy link
Author

OneFaced commented Oct 6, 2017

Changed Write-Host to Write-Verbose to prevent additional (really unneeded) output. Changed Rename-Item to Copy-Item for updating files. Rename-Item would just generate errors.

@OneFaced
Copy link
Author

Added an $arguments variable. Simple to use, just add each argument within a single quote separated by a comma. For example:

$arguments = '-autologin','-maploadinfo'

Default value is no arguments, or $arguments = ''.

@SubActif
Copy link

SubActif commented Oct 24, 2018

I have take your code but updated this to work weel on Win10 :

  • Readd Write-Host in place of Write-Verbose because dont work weel on all system.
  • Add Start-Sleep because player want to read what your code do.
  • Add d3d9_arcdps_extras.dll to this code
  • Add one Stop-Process before instead of Exit because no need to relaunch code for continue control.
  • Rewrite some comments

I had code another file to update file on Win 7 too, using wget.exe

All of this are start by another CMD file who show menus with some another options of maintenance.

I'm dont use github from long time, i dont know how update, so i give you like for all file, in english (used by some player an work well)
https://www.heinze.fr/divers/GuildWars2_Launcher.zip (folder by Win version and language)

NB:
There is only one thing I would have liked to do but no time
It is possible to outsource the varialbe as the file, etc.
In an independent text file and ensure that the two CMDs can retrieve the variables without having to be modified by the user.

As here everyone needs these variables and not written in the same way this poses problems for non-regulars.

Then it's always easier to make them edit a text file than anything else.

I think I can do it but when I have time, and then even write all the other CMD menu in pure PowerShell but I discover at the same time some things and I have to keep in mind that I want it to work for Windows 7 users too!

@OneFaced
Copy link
Author

OneFaced commented Dec 2, 2018

Using Write-Host is bad practice in automation scripts which is why I'm using Write-Verbose. This script typically runs so quickly that Write-Host wouldn't be of much value regardless and using Start-Sleep just delays execution of an unattended script for no useful reason. Exit is a keyword of PoSh; using Stop-Process is just typing extra characters :-)

@OneFaced
Copy link
Author

Updated with d3d9_arcdps_extras.dll.

@OneFaced
Copy link
Author

OneFaced commented May 4, 2020

Removed buildtemplates/extras dlls since they're no longer published.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment