Quantcast
Channel: Ru.Board
Viewing all articles
Browse latest Browse all 1274525

Process Hacker (часть 2) (2920) / Продвинутый мониторинг процессов и служб

$
0
0
Smitis:
Мне посоветовали использовать github api для получения версии и ссылки с github.
Вот вариант этой обновлялки.
[more=ProcessHacker-update-2.ps1]
Код:
# Обновление ProcessHacker с https://github.com/VictorVG/ph
# Обновляются обе версии x86 и x64 которые находятся в соответствующих подпапках x86 и x64 в той же папке, где и скрипт.
# Настройки не переписываются.

$infourl = "https://api.github.com/repos/VictorVG/ph/releases/latest"
$siteurl = "https://github.com/VictorVG/ph"
$archivelink = "https://github.com/VictorVG/ph/raw/master/processhacker-3.0-bin.zip"
$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 {""}

Write-Host "Update ProcessHacker"
Write-Host "Check..."
$info = Invoke-WebRequest $infourl | ConvertFrom-Json
$release = if ($info.tag_name -match '(\d+\.\d+\.\d+\.\d+)') {$matches[1]} {""}
$archivelink = ($info.assets | where {$_.content_type -eq "application/x-zip-compressed"}).browser_download_url
$archive = Join-Path $appdir ([System.IO.Path]::GetFileName($archivelink))

Add-Type -AssemblyName System.IO.Compression
Add-Type -AssemblyName System.IO.Compression.FileSystem

[System.Net.ServicePointManager]::SecurityProtocol = 'SSL3,TLS,TLS11,TLS12'
Write-Host "Release: $release"
Write-Host "Link: $archivelink"
Write-Host "Current version x32: $version32"
Write-Host "Current version x64: $version64"
if ($release -and $archivelink -and ($version32 -ne $release -or $version64 -ne $release)) {
    Write-Host "Download..."
    #Start-BitsTransfer $archivelink -TransferType Download
    Invoke-WebRequest $archivelink -Out $archive
    if (Test-Path -Lit $archive) {
        Write-Host "Unpack..."
        #[System.IO.Directory]::Delete("",$true)
        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")) {
            #New-Item "$appdir\x86\plugins\plugindata" -Type Directory -Force #| Out-Null
            [System.IO.Directory]::CreateDirectory("$appdir\x86\plugins\plugindata") | Out-Null
        }
        if (-not (Test-Path -Lit "$appdir\x64\plugins\plugindata")) {
            #New-Item "$appdir\x64\plugins\plugindata" -Type Directory -Force #| Out-Null
            [System.IO.Directory]::CreateDirectory("$appdir\x64\plugins\plugindata") | Out-Null
        }
        if (-not (Test-Path -Lit "$appdir\x64\x86\plugins")) {
            #New-Item "$appdir\x64\x86\plugins" -Type Directory -Force #| Out-Null
            [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"
}
[/more]
С этим api ещё до конца не разобрался. Например, tag_name возвращает v3.0.6513.1986.1, одна цифра лишняя, поэтому просто её обрезаю.

Viewing all articles
Browse latest Browse all 1274525

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>