MAA自动资源更新 Batch Script for MAA Resources' Auto Update #10403
Closed
gerald-liu
started this conversation in
Show and tell
Replies: 2 comments
-
由于现在有version.json标记版本了,可以更轻松了,不需要用到git,无依赖 try {
$global:progressPreference = 'silentlyContinue'
$remote = (Invoke-WebRequest 'https://github.com/MaaAssistantArknights/MaaResource/raw/main/resource/version.json' | ConvertFrom-Json).last_updated
$local = (Get-Content -Encoding UTF8 -Raw 'resource\version.json' | ConvertFrom-Json).last_updated
if($remote -eq $local){
Write-Host "MAA resource is up to date! Version:$local"
} else {
Write-Host "Downloading MaaResource..." -ForegroundColor Green
Invoke-WebRequest -Uri "https://github.com/MaaAssistantArknights/MaaResource/archive/refs/heads/main.zip" -UserAgent [Microsoft.PowerShell.Commands.PSUserAgent]::FireFox -OutFile "MaaResource-main.zip"
Add-Type -AssemblyName System.IO.Compression.FileSystem
[System.IO.Compression.ZipFile]::ExtractToDirectory('MaaResource-main.zip','.')
Move-Item -Force -Path "MaaResource-main\resource\*" -Destination "resource\"
Move-Item -Force -Path "MaaResource-main\cache\*" -Destination "cache\"
rm -r -force MaaResource-main
rm -force MaaResource-main.zip
Write-Host "MAA resource have updated to $remote!"
}
}
catch [System.Exception] {
Write-Host $_.Exception.Message -ForegroundColor Red
exit 1
} 套一个bat脚本来给MAA调用,让bat的文件名和上面的ps脚本同名就行:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
针对资源不再自动更新的问题(手动更新资源文件方法 | Manual resource update #10033),使用Batch脚本自动更新资源并启动MAA。
使用方法:保存为.bat文件,运行时与MAA.exe置于同一目录,或自行更改
pushd %~dp0
为pushd <absolute_path_to_MAA_directory>
。欢迎交流指正,谢谢!
Regarding the issue of resources not updating automatically (手动更新资源文件方法 | Manual resource update #10033), you can use the following batch script to automatically update resources and start MAA.
Usage: Save it as a .bat file and run it in the directory of MAA.exe (use a desktop shortcut if you like), or change
pushd %~dp0
topushd <absolute_path_to_MAA_directory>
.Feedbacks are welcome, thanks!
Updated on 2024/09/03: bug fixes.
Beta Was this translation helpful? Give feedback.
All reactions