-
Notifications
You must be signed in to change notification settings - Fork 59
/
patch.ps1
42 lines (36 loc) · 1.34 KB
/
patch.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
param(
$path,
$patch
)
$ErrorActionPreference="Stop"
$dest = "tools"
if ((Test-Path $dest) -ne $true){
New-Item $dest -ItemType Directory | Out-Null
}
#####################################################################
# patch
#####################################################################
if (-ne Test-Path "$dest\bin\patch.exe") {
$url = "http://gnuwin32.sourceforge.net/downlinks/patch-bin-zip.php"
$output = "$dest\patch.zip"
"Downloading patch binary" | Write-Host -ForegroundColor DarkGreen
Start-BitsTransfer -Source $url -Destination $output
"Extracting patch binary" | Write-Host -ForegroundColor DarkGreen
Expand-Archive -Path $output -DestinationPath $dest
@"
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<!-- Make sure that UAC believes
that it does not require administrative privilege -->
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
"@ | Out-File -FilePath $dest\bin\patch.exe.manifest -Encoding utf8
(Get-ChildItem $dest\bin\patch.exe).LastWriteTime = Get-Date
}
Get-Content $patch | & $dest\bin\patch.exe -d $path