Smitis
Silver Member | Редактировать | Профиль | Сообщение | ICQ | Цитировать | Сообщить модератору
Код: # Обновление ProcessHacker с https://github.com/VictorVG/ph, вариант 1 со сканированием страницы проекта # Обновляются обе версии x86 и x64 которые находятся в соответствующих подпапках x86 и x64 в той же папке, где и скрипт. # Настройки не переписываются. $siteurl = "https://github.com/VictorVG/ph" $archivelink = "https://github.com/VictorVG/ph/raw/master/processhacker-3.0-bin.zip" $presentmask = 'href="(/[^"]+/processhacker-[\d.]+-bin.zip)"' # патерн для поиска начала ссылки на PH $versionmask = "([\d.]+) Git-[\da-f]+<" # патерн для выделения версии из html Add-Type -AssemblyName System.IO.Compression Add-Type -AssemblyName System.IO.Compression.FileSystem Write-Host "Update ProcessHacker" Write-Host "Check..." $present = $false $release = $false $appdir = $MyInvocation.MyCommand.Path | Split-Path -Parent $exefile32 = Join-Path $appdir "x86\ProcessHacker.exe" $exefile64 = Join-Path $appdir "x64\ProcessHacker.exe" $version32 = if(Test-Path -Lit $exefile32) {(Get-ItemProperty -Lit $exefile32).VersionInfo.FileVersion} else {""} $version64 = if(Test-Path -Lit $exefile64) {(Get-ItemProperty -Lit $exefile64).VersionInfo.FileVersion} else {""} $archive = Join-Path $appdir ([System.IO.Path]::GetFileName($archivelink)) [System.Net.ServicePointManager]::SecurityProtocol = 'SSL3,TLS,TLS11,TLS12' # for Windows 7 $content = (Invoke-WebRequest -URI $siteurl).content -split "`n" # Ищем ссылку на zip-файл и сразу за ним ближайшую строку с версией foreach ($c in $content) { if (-not $present -and $c -match $presentmask) { $present = $true } elseif ($present -and $c -match $versionmask) { $release = $Matches[1] Write-Host "Release: $release" Write-Host "Link: $archivelink" Write-Host "Current version x32: $version32" Write-Host "Current version x64: $version64" if ($version32 -ne $release -or $version64 -ne $release) { Write-Host "Download..." Invoke-WebRequest $archivelink -Out $archive if (Test-Path -Lit $archive) { Write-Host "Unpack..." Remove-Item "$appdir\x86\plugins" -Recurse -Force -EA SilentlyContinue Remove-Item "$appdir\x64\plugins" -Recurse -Force -EA SilentlyContinue Remove-Item "$appdir\x64\x86" -Recurse -Force -EA SilentlyContinue if (-not (Test-Path -Lit "$appdir\x86\plugins\plugindata")) { [System.IO.Directory]::CreateDirectory("$appdir\x86\plugins\plugindata") | Out-Null } if (-not (Test-Path -Lit "$appdir\x64\plugins\plugindata")) { [System.IO.Directory]::CreateDirectory("$appdir\x64\plugins\plugindata") | Out-Null } if (-not (Test-Path -Lit "$appdir\x64\x86\plugins")) { [System.IO.Directory]::CreateDirectory("$appdir\x64\x86\plugins") | Out-Null } $zip = [System.IO.Compression.ZipFile]::OpenRead($archive) $zip.Entries | foreach { $fullname = $_.FullName $fullpath = Join-Path $appdir $fullname if (".xml",".txt" -notcontains [System.IO.Path]::GetExtension($_.FullName) -and $_.FullName -notmatch "/$") { #Write-Host $_.FullName $saveStream = [System.IO.File]::Create($_.FullName) $zipStream = $_.Open() $zipStream.CopyTo($saveStream) $zipStream.Close() $zipStream.Dispose() $saveStream.Close() $saveStream.Dispose() } } $zip.Dispose() Remove-Item $archive -Force } Write-Host "Done" } break } } |
| Всего записей: 3218 | Зарегистр. 09-02-2003 | Отправлено: 11:46 27-11-2018 | Исправлено: Smitis, 11:02 18-12-2018 |
|