Last active
November 11, 2018 18:40
-
-
Save Winding6636/207f6484fb1254f8470a52623e71b591 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################################################### | |
# | |
# NowPlaying Auto Update Script's | |
# | |
# Auther: NekotenYuuna | |
# Date:Ver.1.1 rev.50 | |
# | |
# Copyright© Sys-in,Kazuki All Rights Reserved. | |
########################################################### | |
#Env | |
$DirName="" #NowPlayingDirectoryName | |
$InstallPath="" #NowPlayingDirectoryPath | |
$Script:InstallDir = $InstallPath+$DirName #ぶっちゃけここにNowPlayingV2.exeがあるディレクトリ書けばいいよ。 | |
$Script:WgetAdd = "https://github.com/tumugin/NowPlayingV2/releases/download/"+$latesver+"/NowPlayingV2_"+$latescode+".zip" | |
$Script:LatestZip = "NPLatest.zip" | |
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; | |
function main(){ | |
Write-Host ".:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:." "NowPlaying V2 UpdateScript" ".:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:." | |
checker | |
} | |
function checker($Script:WgetAdd){ | |
$currentver = (Get-Command $Script:InstallDir\NowPlayingV2.exe).FileVersionInfo.FileVersion | |
$latesver = [system.Text.Encoding]::UTF8.GetString((Invoke-WebRequest "https://raw.githubusercontent.com/tumugin/NowPlayingV2/master/NowPlayingV2/Updater/version.json").RawContentStream.ToArray()) | ConvertFrom-Json | ForEach-Object AppVersion | |
$latescode = $latesver.Replace('.', '') | |
$Script:WgetAdd = "https://github.com/tumugin/NowPlayingV2/releases/download/"+$latesver+"/NowPlayingV2_"+$latescode+".zip" | |
if ( $latesver -gt $currentver){ | |
Write-Host "新しいバージョンがあります。"`n"現在のバージョン:"$currentver`n"最新バージョン:"$latesver | |
latestget | |
} else { | |
Write-Host "最新バージョンです。" | |
exit 0 | |
} | |
} | |
function latestget(){ | |
Write-Host "バージョン更新をします。" | |
try{Write-Host "ダウンロードを開始します。 $Script:LatestZip" | |
Invoke-WebRequest -Uri $Script:WgetAdd -OutFile $Script:LatestZip | |
Write-Host "$latesver を $Script:LatestZip でダウンロードしました。" | |
}catch [System.Net.WebException]{$statusCode = $_.Exception.Response.StatusCode; | |
Write-Host "ダウンロードエラー ステータス: $statusCode" | |
} | |
Write-Host "NowPlayingが起動していたら終了します。" | |
Start-Sleep -s 3 | |
$null = TASKKILL /F /IM NowPlayingV2.exe 2>&1 | |
$null = TASKKILL /F /IM iTunesNPPlugin.exe 2>&1 | |
Write-Host "更新を適用しています。" | |
Expand-Archive -Path $Script:LatestZip -OutputPath $Script:InstallDir -Force -ShowProgress | |
Write-Host "更新を適用しました。" "赤文字でエラーが出ている場合はそれを確認してください。" | |
Remove-Item $Script:LatestZip | |
} | |
#.:.:.:.:.:.:.:.:. | |
Switch ($args[0]) { | |
"debug" {} | |
"reinstall" {Write-Host ".:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:." "NowPlaying V2 UpdateScript" ".:.:.:.:.:.:.:.:.:.:.:.:.:.:.:.:." | |
$currentver = (Get-Command $Script:InstallDir\NowPlayingV2.exe).FileVersionInfo.FileVersion | |
$latesver = [system.Text.Encoding]::UTF8.GetString((Invoke-WebRequest "https://raw.githubusercontent.com/tumugin/NowPlayingV2/master/NowPlayingV2/Updater/version.json").RawContentStream.ToArray()) | ConvertFrom-Json | ForEach-Object AppVersion | |
$latescode = $latesver.Replace('.', '') | |
$Script:WgetAdd = "https://github.com/tumugin/NowPlayingV2/releases/download/"+$latesver+"/NowPlayingV2_"+$latescode+".zip" | |
latestget | |
Remove-Item $Script:LatestZip | |
} | |
default{main} | |
} | |
exit 0 | |
#.:.:.:.:.:.:.:.:. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment