Skip to content
This repository has been archived by the owner on Aug 4, 2023. It is now read-only.

Commit

Permalink
Fixes #2
Browse files Browse the repository at this point in the history
  • Loading branch information
solacelost committed Mar 1, 2020
1 parent 1aa142f commit c8da378
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Bootstrap-ArcDPS.ps1
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<# Run this with the following:
powershell -c "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; ; iex(New-Object Net.WebClient).DownloadString('https://github.com/solacelost/update-arcdps/raw/0.3.4/Bootstrap-ArcDPS.ps1')"
powershell -c "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; ; iex(New-Object Net.WebClient).DownloadString('https://github.com/solacelost/update-arcdps/raw/0.3.5/Bootstrap-ArcDPS.ps1')"
#>

# First, download the Update-ArcDPS.ps1 script
$ScriptPath = $env:APPDATA + '\Update-ArcDPS.ps1'
Invoke-WebRequest "https://github.com/solacelost/update-arcdps/raw/0.3.4/Update-ArcDPS.ps1" -OutFile $ScriptPath
Invoke-WebRequest "https://github.com/solacelost/update-arcdps/raw/0.3.5/Update-ArcDPS.ps1" -OutFile $ScriptPath

$desktop = [system.environment]::GetFolderPath("Desktop")

Expand Down
44 changes: 36 additions & 8 deletions Update-ArcDPS.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@
.NOTES
Name: Update-ArcDPS.ps1
Author: James Harmison
SCRIPT VERSION: 0.3.4
SCRIPT VERSION: 0.3.5
Requires: Powershell v5 or higher.
Version History:
0.3.5 - Check for write permissions on binpath and correct them if we don't
have access.
0.3.4 - Corrected scriptversion variable (I really need to automate updating
versions between tags)
0.3.3 - Fixed bad verb (Until vs While !)
Expand Down Expand Up @@ -113,7 +115,7 @@ param (
[string]$SearchPath="C:\Program F*"
)

$scriptversion = '0.3.4'
$scriptversion = '0.3.5'
$needsupdate = $false

Function Download-Folder([string]$src,
Expand Down Expand Up @@ -305,11 +307,6 @@ Function Get-YesOrNo([string]$prompt) {
}

$DesktopDir = [system.environment]::GetFolderPath("Desktop")
$SetupScript = "$DesktopDir\Update-ArcDPS Setup.lnk"
if (Test-Path $SetupScript) {
Write-Host "Removing Bootstrapped setup shortcut"
Remove-Item -Force -Path $SetupScript
}

if ($Remove) {
# Import the statefile and remove it, or find GW2 to identify Arc files in
Expand Down Expand Up @@ -428,7 +425,7 @@ if (Test-Path $StateFile) {

$state | Export-Clixml -path $StateFile

if ($state['autoupdate'] -or $AutoUpdate) {
if ($state.autoupdate -or $AutoUpdate) {
$UpdateInfo = $(Invoke-WebRequest https://api.github.com/repos/solacelost/update-arcdps/releases/latest)
$LatestVersion = $(ConvertFrom-Json $UpdateInfo.content).tag_name
if ($LatestVersion -ne $scriptversion) {
Expand Down Expand Up @@ -457,6 +454,37 @@ $src = 'https://www.deltaconnected.com/arcdps/x64/'
# To our GW2/bin64 directory
$dst = $state.binpath

$testpath = $($state.binpath + "/test.txt")
Write-Output "Test" | Out-File -EA 0 -FilePath $testpath
if ( $(Get-Content $testpath -EA SilentlyContinue | Measure-Object).count -eq 0) {
Write-Host "We need to enable permissions for you to be able to install/update ArcDPS.`n"
Write-Host "Please accept the Windows UAC prompt if/when it appears to enable this functionality."
pause
$Acl = Get-Acl $state.binpath
$UserPrincipal = $(Get-Acl $env:appdata).Owner
$Ar = New-Object System.Security.AccessControl.FileSystemAccessRule(
$UserPrincipal, "FullControl", "ContainerInherit,ObjectInherit", "None", "Allow"
)
$Acl.SetAccessRule($Ar)
$modify_path = $state.binpath
$xml_path = $($env:temp + "/acl.xml")
$Acl | Export-Clixml -path $xml_path
Start-Process -FilePath powershell.exe -Verb RunAs -ArgumentList "`$Acl = `$(Import-Clixml $xml_path) ; Set-Acl `"$modify_path`" `$Acl"
Remove-Item $xml_path
Write-Host "The directory permissions should have been modified by the pop-up window.`n"
Write-Host "We need to exit and relaunch the script to enable access."
pause
exit
}


$SetupScript = "$DesktopDir\Update-ArcDPS Setup.lnk"
if (Test-Path $SetupScript) {
Write-Host "Removing Bootstrapped setup shortcut"
Remove-Item -Force -Path $SetupScript
}


# Recursively, so we grab all subfolders too
# NOTE: Download-Folder checks modification date and won't update if the listing
# shows that we have the same version
Expand Down
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ However, some of my guild mates had a hard time downloading ArcDPS or rememberin
![Right Clicking Run](./docs_run.png)
2. Copy the following and paste it into the "Open:" text box:
```
powershell -c "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; ; iex(New-Object Net.WebClient).DownloadString('https://github.com/solacelost/update-arcdps/raw/0.3.4/Bootstrap-ArcDPS.ps1')"
powershell -c "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; ; iex(New-Object Net.WebClient).DownloadString('https://github.com/solacelost/update-arcdps/raw/0.3.5/Bootstrap-ArcDPS.ps1')"
````

![Run Dialog](./docs_run2.png)
Expand All @@ -26,7 +26,7 @@ However, some of my guild mates had a hard time downloading ArcDPS or rememberin
### The auditable way
1. Download the latest Release from [the releases page](https://github.com/solacelost/update-arcdps/releases).
1. Unzip it to the directory of your choice - the location doesn't matter
1. Review the script on your computer to ensure you're okay with what it does - you only need the Update-ArcDPS.ps1 script, not the Bootstrap. You can reach it via the [raw URL](https://raw.githubusercontent.com/solacelost/update-arcdps/0.3.4/Update-ArcDPS.ps1) and copy/paste, if you like.
1. Review the script on your computer to ensure you're okay with what it does - you only need the Update-ArcDPS.ps1 script, not the Bootstrap. You can reach it via the [raw URL](https://raw.githubusercontent.com/solacelost/update-arcdps/0.3.5/Update-ArcDPS.ps1) and copy/paste, if you like.
1. Open a PowerShell window with the -executionpolicy Bypass option set and run the script with -CreateShortcut:
1. Suppose you unzipped Update-ArcDPS.ps1 to your Desktop on the user named James.
1. Right click on your Start button and click "Run", or press Ctrl+R on your keyboard.
Expand Down

0 comments on commit c8da378

Please sign in to comment.