3

所以我对这里的批处理很陌生,我试图为需要对 jar 进行的一些修改制作一个自动安装程序。

当我将文件拖过来时它会执行,但我不知道如何告诉它执行文件而不将其拖放到上面

所以你知道 7za 应用程序用于提取,正如我所说,如果我拖放我想要 forge.zip 解压缩并注入 minecraft.jar 的文件,这将有效

set_source=%APPDATA%\Roaming\.minecraft\bin\forge.zip
set path="%USERPROFILE%";%path%
move 7za.exe %USERPROFILE%
cd %USERPROFILE%
7za x AppData\Roaming\.minecraft\bin\minecraft.jar -oAppData\Roaming\.minecraft\bin\TempStuff\
7za x %* -oAppData\Roaming\.minecraft\bin\TempStuff\ -y
cd %USERPROFILE%\AppData\Roaming\.minecraft\bin\TempStuff\
rmdir /S /Q META-INF
cd %USERPROFILE%\AppData\Roaming\.minecraft\bin
ren minecraft.jar "minecraft_c.jar"
cd %USERPROFILE%
7za a -r minecraft.jar %USERPROFILE%\AppData\Roaming\.minecraft     \bin\TempStuff\* -o%USERPROFILE%\AppData\Roaming\.minecraft\bin
cd %USERPROFILE%\AppData\Roaming\.minecraft\bin
rmdir /S /Q TempStuff
cd %USERPROFILE%
move /y %USERPROFILE%\minecraft.jar %USERPROFILE%\AppData\Roaming\.minecraft\bin
pause

这应该覆盖 jar 中的核心文件以允许修改的文件。抓住是的,我确实看过其他人的替换代码,但我想我在某个地方搞砸了...... :(

解决方案

set path="%USERPROFILE%";%path%
move 7za.exe %USERPROFILE%
cd %USERPROFILE%
7za x AppData\Roaming\.minecraft\bin\minecraft.jar -oAppData\Roaming\.minecraft\bin\TempStuff\
7za x "%USERPROFILE%\AppData\Roaming\.minecraft\JarMods\*.zip" -oAppData\Roaming\.minecraft\bin\TempStuff\ -y
cd %USERPROFILE%\AppData\Roaming\.minecraft\bin\TempStuff\
rmdir /S /Q META-INF
cd %USERPROFILE%\AppData\Roaming\.minecraft\bin
ren minecraft.jar "minecraft_c.jar"
cd %USERPROFILE%
7za a -r minecraft.jar %USERPROFILE%\AppData\Roaming\.minecraft\bin\TempStuff\* -o%USERPROFILE%\AppData\Roaming\.minecraft\bin
cd %USERPROFILE%\AppData\Roaming\.minecraft\bin
rmdir /S /Q TempStuff
cd %USERPROFILE%
move /y %USERPROFILE%\minecraft.jar %USERPROFILE%\AppData\Roaming\.minecraft\bin
cd %APPDATA%\Roaming\.minecraft
mkdir mods
move "%USERPROFILE%\<insert ModInstall path here>\OtherMods\"       %USERPROFILE%\AppData\Roaming\.minecraft\mods
4

1 回答 1

1

作者提出了解决方案,但从那以后就没有回到 SO,所以他的解决方案现在将放在这里:

set path="%USERPROFILE%";%path%
move 7za.exe %USERPROFILE%
cd %USERPROFILE%
7za x AppData\Roaming\.minecraft\bin\minecraft.jar -oAppData\Roaming\.minecraft\bin\TempStuff\
7za x "%USERPROFILE%\AppData\Roaming\.minecraft\JarMods\*.zip" -oAppData\Roaming\.minecraft\bin\TempStuff\ -y
cd %USERPROFILE%\AppData\Roaming\.minecraft\bin\TempStuff\
rmdir /S /Q META-INF
cd %USERPROFILE%\AppData\Roaming\.minecraft\bin
ren minecraft.jar "minecraft_c.jar"
cd %USERPROFILE%
7za a -r minecraft.jar %USERPROFILE%\AppData\Roaming\.minecraft\bin\TempStuff\* -o%USERPROFILE%\AppData\Roaming\.minecraft\bin
cd %USERPROFILE%\AppData\Roaming\.minecraft\bin
rmdir /S /Q TempStuff
cd %USERPROFILE%
move /y %USERPROFILE%\minecraft.jar %USERPROFILE%\AppData\Roaming\.minecraft\bin
cd %APPDATA%\Roaming\.minecraft
mkdir mods
move "%USERPROFILE%\<insert ModInstall path here>\OtherMods\"       %USERPROFILE%\AppData\Roaming\.minecraft\mods
于 2014-05-08T04:07:53.700 回答